您可以修改某些註冊表項以使其可以在設備上運行任何可執行文件。在默認的Windows Mobile 6.0設備上,您會看到「是否允許_.exe運行?」彈出。如果您單擊是,並且程序使註冊表修改並重新啓動設備,則任何應用程序都可以運行。
// Checks to see if the policies in the registry need to be adjusted to allow
// an unsigned program to run. This also affects WCELOAD.EXE as well.
// This is needed to run some programs on Windows Mobile 6 from an unsigned application.
void UpdatePolicy()
{
BOOL bPolicyNeedsUpdate = FALSE;
DWORD dwExistingPolicy = 0;
DWORD dwNewPolicy = 0;
HKEY hKey = NULL;
DWORD dwSize = sizeof(DWORD);
RegCreateKeyEx(HKEY_LOCAL_MACHINE, _T("Security\\Policies\\Policies"), 0, NULL, 0,
KEY_ALL_ACCESS, NULL, &hKey, NULL);
// See if the policy has already been adjusted.
if (hKey != NULL)
{
DWORD dwType = 0;
RegQueryValueEx(hKey, _T("0000101a"), NULL, &dwType, (LPBYTE)&dwExistingPolicy, &dwSize);
if (dwExistingPolicy != 1)
bPolicyNeedsUpdate = TRUE;
}
if (bPolicyNeedsUpdate)
{
// Adjust the policy
dwNewPolicy = 1;
RegSetValueEx(hKey, _T("0000101a"), NULL, REG_DWORD, (const BYTE*)&dwNewPolicy, dwSize);
RegSetValueEx(hKey, _T("00001001"), NULL, REG_DWORD, (const BYTE*)&dwNewPolicy, dwSize);
dwNewPolicy = 40;
RegSetValueEx(hKey, _T("00001005"), NULL, REG_DWORD, (const BYTE*)&dwNewPolicy, dwSize);
dwNewPolicy = 144;
RegSetValueEx(hKey, _T("00001017"), NULL, REG_DWORD, (const BYTE*)&dwNewPolicy, dwSize);
// Reboot so the changes take effect
Reboot();
}
RegCloseKey(hKey);
}
void Reboot()
{
SetSystemPowerState(NULL, POWER_STATE_RESET, 0);
}
我已經發布了一種方法來刪除某些Windows Mobile設備在C++中的代碼簽名要求。 – 2011-07-16 02:19:22