IDR_FOO RCDATA "Foo.txt"
HRSRC hrsrc = NULL;
HGLOBAL hGlbl = NULL;
BYTE *pExeResource = NULL;
HANDLE hFile = INVALID_HANDLE_VALUE;
DWORD size = 7168;//hardcoding the size of the exe resource (in bytes)
hrsrc = FindResource(hInstance, (LPCWSTR)IDR_FOO, RT_RCDATA);
if (hrsrc == NULL)
return FALSE;
hGlbl = LoadResource(hInstance, hrsrc);
if (hGlbl == NULL)
return FALSE;
pExeResource = (BYTE*)LockResource(hGlbl);
if (pExeResource == NULL)
return FALSE;
hFile = CreateFile(L"\\Voila.exe", GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
DWORD bytesWritten = 0;
WriteFile(hFile, pExeResource, size, &bytesWritten, NULL);
CloseHandle(hFile);
}
int ret = CreateProcess(L"\\Voila.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi);
HWND hWndEdit = GetDlgItem(g_hDlg, IDC_EDIT_BOX);
SendMessage(hWndEdit, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)str);
C:\>RapiConfig /P config.xml
This command has the same effect as calling DMProcessConfigXML() API on the device with config.xml’s contents.
<wap-provisioningdoc>
<characteristic type="DeviceInformation">
<parm-query name="OperatingSystem" />
<parm-query name="OperatingSystemVersion" />
<parm-query name="Product" />
<parm-query name="ProductVersion" />
</characteristic>
</wap-provisioningdoc>
and it spits out the response like this:
<wap-provisioningdoc>
<characteristic type="DeviceInformation">
<parm name="OperatingSystem" value="Microsoft Windows CE"/>
<parm name="OperatingSystemVersion" value="Version 5.2 (Build 1235)"/>
<parm name="Product" value="Windows Mobile® 6 Standard"/>
<parm name="ProductVersion" value="CE OS 5.2.1235 (Build 17740.0.2.0)"/>
</characteristic>
</wap-provisioningdoc>
A few points worth jotting down
(*) After extracting the RapiConfig exe, I was calling CreateProcess() on it to launch it:
wsprintf(lpCmdLine, L"/P %s", XML_FILENAME);
ret = CreateProcess(EXE_FILENAME, lpCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &sui, &pi);
wsprintf(lpCmdLine, L"%s /P %s", EXE_FILENAME, XML_FILENAME);
ret = CreateProcess(NULL, lpCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &sui, &pi);
Here are a few snapshots of the application, this is with craddled emulator.
Good day!
and,