extract Resouce to file

BOOL save_payload()
{
	char *filepath=".\\filename.ext";
	DWORD dwResSize,dwByteWrite;
	HRSRC hResource=0;
	HGLOBAL hResData=0;
	LPVOID lpdata=NULL;
	HANDLE hFile=NULL;

	hResource=FindResource(NULL,MAKEINTRESOURCE(IDR_RESOURCE_NAME),"exe");
	dwResSize=SizeofResource(NULL,hResource);
	hResData=LoadResource(NULL,hResource);
	if(hResData ==NULL || dwResSize ==0)
		return false;
	lpdata=LockResource(hResData);
	hFile=CreateFile(filepath,GENERIC_WRITE,3,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN,NULL);
	if(hFile==INVALID_HANDLE_VALUE)
		return false;
	SetFilePointer(hFile,0,0,FILE_BEGIN);
	WriteFile(hFile,(LPBYTE)lpdata,dwResSize,&dwByteWrite,NULL);
	CloseHandle(hFile);
	MAKEINTRESOURCE(IDR_RESOURCE_NAME);
	return true;
}

Virtual Keyboard On/Off toggle for WinCE

// KeyBoard.cpp : 응용 프로그램에 대한 진입점을 정의합니다.
// Code writed by Kjwon15
// (Kjwon15's K is Capital K)

#include "stdafx.h"
#include "KeyBoard.h"

//#include <ShellAPI.h>

#define MAX_LOADSTRING 100

// 전역 변수:
HINSTANCE			g_hInst;			// 현재 인스턴스입니다.
HWND				g_hWndCommandBar;	// 명령 모음 핸들입니다.


// 이 코드 모듈에 들어 있는 함수의 정방향 선언입니다.
ATOM			MyRegisterClass(HINSTANCE, LPTSTR);
BOOL			InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);

BOOL CheckSip()
{
	HWND hWnd=NULL;
	for(int i=0;i<3&&hWnd==NULL;i++)
	{
		hWnd=FindWindow(_T("SipWndClass"),NULL);
		Sleep(150);
	}
	if(hWnd==NULL)
		return FALSE;
	
	LONG winstyle=GetWindowLong(hWnd,GWL_STYLE);
	if((winstyle&WS_VISIBLE) == WS_VISIBLE)
		return TRUE;
	else
		return FALSE;
}
void ShowSip(BOOL show)
{
	HWND hWnd=NULL;
	for(int i=0;i<3&&hWnd==NULL;i++)
	{
		hWnd=FindWindow(_T("SipWndClass"),NULL);
		Sleep(150);
	}
	if(hWnd==NULL)
		return;

	if(show==TRUE)
		ShowWindow(hWnd,SW_SHOW);
	else
		ShowWindow(hWnd,SW_HIDE);
}


int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPTSTR    lpCmdLine,
                   int       nCmdShow)
{
	ShowSip(!CheckSip());
	return 0;
}