1. Write a little program (ShellExe.exe) to start the
application software (For example: MyApp.exe)and Explorer.exe
(1) Use VS2005 to build a smart device program (Attention: in the setting guide please choose the program type as WINDOWS application program)
(2) Program code as below. (The guide will generate a lot of code, for example, window process function and so on. They are useless. Delete them and keep the head file and WinMain function would be enough)
(1) Use VS2005 to build a smart device program (Attention: in the setting guide please choose the program type as WINDOWS application program)
(2) Program code as below. (The guide will generate a lot of code, for example, window process function and so on. They are useless. Delete them and keep the head file and WinMain function would be enough)
#define MYAPP_PATH (L"\\Storage
Card\\MyApp.exe") //application software path( at SD card,of course you can
change the path according to the real situation)
#define MYAPP_STARTUP (L"\\Storage
Card\\MyAppStartup.txt") //the file in this path used to identify if the
application software started yet. The file should be build in the application
software(MyApp.exe)
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
PROCESS_INFORMATION processinfo;
WIN32_FIND_DATA stFindData;
HANDLE hFile = INVALID_HANDLE_VALUE;
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
PROCESS_INFORMATION processinfo;
WIN32_FIND_DATA stFindData;
HANDLE hFile = INVALID_HANDLE_VALUE;
//wait until SD card file load finished
int nCount = 20; //This value should be big enough. Or it may can’t wait until SD card load file.
while(nCount--)
{
hFile = ::FindFirstFile(MYAPP_PATH, &;stFindData);
Sleep(500);
if(INVALID_HANDLE_VALUE != hFile)
{
break;
}
}
//if the file loading overtime, enter into Window Explore, return
if(0 >;= nCount)
{
// start explorer.exe
CreateProcess(L"\\Windows\\explorer.exe",NULL,NULL,NULL,NULL,
CREATE_NEW_CONSOLE,NULL,NULL,NULL,&;processinfo);
return 0;
}
FindClose(hFile);
int nCount = 20; //This value should be big enough. Or it may can’t wait until SD card load file.
while(nCount--)
{
hFile = ::FindFirstFile(MYAPP_PATH, &;stFindData);
Sleep(500);
if(INVALID_HANDLE_VALUE != hFile)
{
break;
}
}
//if the file loading overtime, enter into Window Explore, return
if(0 >;= nCount)
{
// start explorer.exe
CreateProcess(L"\\Windows\\explorer.exe",NULL,NULL,NULL,NULL,
CREATE_NEW_CONSOLE,NULL,NULL,NULL,&;processinfo);
return 0;
}
FindClose(hFile);
SHELLEXECUTEINFO ShExeInfo={0};
//execute MyApp.exe
ShExeInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExeInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExeInfo.hwnd = NULL;
ShExeInfo.lpVerb = NULL;
ShExeInfo.lpFile = MYAPP_PATH;
ShExeInfo.lpParameters = L"";
ShExeInfo.lpDirectory = NULL;
ShExeInfo.nShow = SW_SHOW;
ShExeInfo.hInstApp = NULL;
ShellExecuteEx(&;ShExeInfo);
while(1)
{
//open the exist file which is build in the application program (MyApp.exe)
hFile = CreateFile(MYAPP_STARTUP, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
{
//open the exist file which is build in the application program (MyApp.exe)
hFile = CreateFile(MYAPP_STARTUP, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
// if the file is not exist, that means the application
program have not started yet.
if(hFile == INVALID_HANDLE_VALUE)
{
//sleep 10ms
Sleep(10);
}
else
{
// close the file
CloseHandle(hFile);
// delete the file
DeleteFile(MYAPP_STARTUP);
if(hFile == INVALID_HANDLE_VALUE)
{
//sleep 10ms
Sleep(10);
}
else
{
// close the file
CloseHandle(hFile);
// delete the file
DeleteFile(MYAPP_STARTUP);
// start explorer.exe
CreateProcess(L"\\Windows\\explorer.exe",NULL,NULL,NULL,NULL,
CREATE_NEW_CONSOLE,NULL,NULL,NULL,&;processinfo);
break;
}
}
return 0;
}
CreateProcess(L"\\Windows\\explorer.exe",NULL,NULL,NULL,NULL,
CREATE_NEW_CONSOLE,NULL,NULL,NULL,&;processinfo);
break;
}
}
return 0;
}
2. Modify the
regedit
change:
[HKEY_LOCAL_MACHINE\init]
"Launch50"="explorer.exe"
"Depend50"=hex:14,00, 1e,00
as:
[HKEY_LOCAL_MACHINE\init]
"Launch50"="ShellExe.exe"
"Depend50"=hex:14,00, 1e,00
change:
[HKEY_LOCAL_MACHINE\init]
"Launch50"="explorer.exe"
"Depend50"=hex:14,00, 1e,00
as:
[HKEY_LOCAL_MACHINE\init]
"Launch50"="ShellExe.exe"
"Depend50"=hex:14,00, 1e,00
3. Put the content “ ShellExe.exe $(_FLATRELEASEDIR)\ShellExe.exe NK S” in the ”FILES” label of files X:\WINCE600\PLATFORM\SMDK2450\CESYSGEN\files\platform.bib
and
C:\WINCE600\PLATFORM\SMDK2450\FILES\platform.bib.
4. Copy the built ShellExe.exe executive file to the system file
folder. For example, the “FILES” folder in mini 2440 directory. If it is
fast-compile, copy it to the directory: \RelDir\smdk2450_ARMV4I_Release.
5. Now we can start to compile. If you have compiled NK, then can use [generate]->;[Make Run-Time Image] to run fast-compile.
没有评论:
发表评论