There are three implementation methods for Automatic startup in WM:
1. Place the shortcut of the .exe file in the \ windows \ Startup directory.
2. Modify the Registry: (the Code is as follows)
// Write to the Registry and start automatically upon startup
Hkey = NULL;
// Locate the system startup Item
Lpctstr lprun = text ("init ");
// Open the startup key
Long LRET = regopenkeyex (HKEY_LOCAL_MACHINE, lprun, 0, key_write, & hkey );
If (LRET = error_success)
{
Tchar pfilename [max_path] = {0 };
// Obtain the full path of the program.
DWORD dwret = getmodulefilename (null, pfilename, max_path );
// Add hide Parameters
// Wcscat_s (pfilename, max_path + 5, text ("hide "));
// Add a sub-key and set the value
LRET = regsetvalueex (hkey, text ("launch90"), 0, REG_SZ, (byte *) (pfilename), (dwret) * sizeof (tchar ));
// Close the registry
Regclosekey (hkey );
If (LRET! = Error_success)
{
MessageBox (hwnd, text ("system parameter error, cannot start with system"), null, mb_okcancel );
}
Else
{
MessageBox (hwnd, text ("successfully set to auto-start"), null, mb_okcancel );
}
}
Put the above Code into the place where it can be executed when the program is running, and then it can be self-started when it is started again.
3. Use the Microsoft example to make the project into a service
Microsoft Project Directory: C: \ Program Files \ Windows Mobile 6 SDK \ samples \ common \ CPP \ Win32 \ setupdll