Making the Pocket PC installer under WinCe platform

xiaoxiao2021-03-06  42

Seeing that some people often ask, how to install the Pocket PC application from the desktop system. Here, a Win32 SDK written for the previous reference to VCHELP Murry, and put it up. I hope to provide some reference for the application installer under making WINCE. The specific steps are as follows: 1. Create a new Win32 project in VS.NET 2003, named Setup. Select an empty project to generate a project.

2. In the project menu, select Add new item. Or directly Press CTRL SHIFT A to add a C file, and name it to setup into the following code: / *********************** ******************************************************* ** File name: setup.cpp ** Major class: setup.cpp ** ** Copyright (c) ** Create a person: Liu_sir ** Japan: 2004-07-29 ** Modifier: ** Japan: ** Description: Install the PDA application Pocket PC (Note: There must be a setup.ini file in the root directory) ** ×× Main steps: (1) Confirmation condition ** (2) Take your own path and take the Ini path ** (3) Take CEAPPMGR.EXE full path ** (4) Start installation ** (5) Exit ** ** version: 1.0.0 ** 备 Note: Names of each component, code writing compliance with C coding specification ** * ********************************************************** ********************** / #include #include #include #include #include #include #include

INT apientry Winmain (Hinstance Hinstance, LPSTR LPCMDLINSTANCE, INT NCMDSHOW) {// 1. Verify that condition IF (MessageBox (NULL, (LPCTSTR) _t ("Please confirm before installation: / r / n 1. Already installed ActiveSync . / r / n 2. PDA connection to the PC. Is the condition satisfied? "), (lpctstr) _t (" inquiry condition "), MB_YESNO | MB_ICONQUESTION! = iDyes) {Return 0; // Do not satisfy the conditions, exit} // 2. Take your own path Tchar Szpath [MAX_PATH]; getModuleFileName (null, szpath, max_path-1); tchar TMPPATH [MAX_PATH]; // Convert into Ilen = WCSLEN (SZPATH); // #Else Ilen = Strlen (Szpath); #ENDIF

#if _unicode wcscpy (& Szpath [Ilen-3], _T ("ini")); WSPRINTF (TMPPATH, _T ("/"% s / "), szpath); // pay attention to" WCSCPY (Szpath, TMPPATH ); #ELSE STRCPY (& SZPATH [ILEN-3], _T ("ini")); sprintf (tmp path, _t ("/"% s / "), szpath); strcpy (szpath, tmp path); # ENDIF / . / 3 of the full path taken Ceappmgr.exe HKEY hResult; TCHAR szCEAppMgr [] = _ T ( "software // Microsoft // Windows // CurrentVersion // App paths // CEAppMgr.exe"); LONG iRet = RegOpenKeyEx (HKEY_LOCAL_MACHINE, szCEAppMgr, NULL, KEY_READ, & hResult); BYTE szCEAppMgrExe [MAX_PATH * 2 1]; if (iRet == ERROR_SUCCESS) {DWORD cbName, dwType; cbName = MAX_PATH; dwType = REG_SZ; iRet = RegQueryValueEx (hResult, NULL, NULL, & dwtype, SzceAppmgrexe, & cbname); RegcloseKey (HRESULT);} f (IRET! = Error_Success) {MessageBox (NULL, _T ("Please install Microsoft ActiveSync Software!"), _T ("error", MB_ICONEROR); RETURN 1 } Tchar szexe [max_path * 2 2]; #if _unicode wcscpy (szexe, (tchar *) szceAppmgrexe); #ELSE STRCPY (Szexe, (char *) szceAppmgrexe); #ENDIF

// 4 to start the installation SHELLEXECUTEINFO ExecInfo; memset ((TCHAR *) & ExecInfo, 0, sizeof (ExecInfo)); ExecInfo.cbSize = sizeof (ExecInfo); ExecInfo.hwnd = NULL; ExecInfo.lpDirectory = NULL; ExecInfo.hInstApp = Hinstance; execInfo.lpverb = _t ("open");

EXECINFO.LPFILE = SZEXE; execinfo.lpparameters = szpath; execinfo.nshow = SW_SHOW;

:: ShellexecuteEx (& Execinfo); // 5. Exit Return 0;} Mainly call CEAPPMGR.exe, then pass the setup.ini to it.

3.Setup.ini file content: Suppose your program name is PocketApp_ppc, then you should write as follows: [CEAPPManager] Version = 1.0 Component = App

转载请注明原文地址:https://www.9cbs.com/read-53375.html

New Post(0)