QA: How to implement autorun from a storage card?
By Joao Paulo Figueira, June 02, 2003.
Print version
Question
I want to start an application when the user inserts or removes a storage card. How do I implement such functionality?
Answer
You can execute an application when a storage card is inserted or removed from your device. This may allow your users to install applications, perform backups, or other action you like. The protocol is really simple:
Create one directory under the root of the card named after your CPU's ID. For instance, StrongARM is 2577, SH3 is 10003 and MIPS is 4000.
Your application must be named autorun.exe and it must be in that directory.
When the card is inserted, the application is called with 'install' as the command line parameter. When the card is removed, the parameter is 'uninstall'.
Here is a skeleton application. You can create it using eVC's Wizard, choosing the 'WCE Pocket PC 2002 Application'.
TCHAR szCFPath [MAX_PATH+1]; // Compact Flash path
// OnCardInsert
//
// The compact flash card has been inserted
//
void OnCardInsert()
{
//
// Get the path from where we are starting up
//
if(!SHGetAutoRunPath(szCFPath))
{
return;
}
}
// OnCardRemove
//
// The compact flash card has been removed
//
void OnCardRemove()
{
}
// WinMain
//
// Main entry point
//
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
if(lstrcmpi(lpCmdLine, _T("install")) == 0)
{
//
// Card has been inserted
//
OnCardInsert();
}
else if(lstrcmpi(lpCmdLine, _T("uninstall")) == 0)
{
//
// Card has been removed
//
OnCardRemove();
}
return 0;
}
Note that your application does not know where it is starting. You cannot infer that the startup path will be the one you are expecting.
Related resources:
[출처]
http://www.pocketpcdn.com/articles/autorun.html
By Joao Paulo Figueira, June 02, 2003.
Print version
Question
I want to start an application when the user inserts or removes a storage card. How do I implement such functionality?
Answer
You can execute an application when a storage card is inserted or removed from your device. This may allow your users to install applications, perform backups, or other action you like. The protocol is really simple:
Create one directory under the root of the card named after your CPU's ID. For instance, StrongARM is 2577, SH3 is 10003 and MIPS is 4000.
Your application must be named autorun.exe and it must be in that directory.
When the card is inserted, the application is called with 'install' as the command line parameter. When the card is removed, the parameter is 'uninstall'.
Here is a skeleton application. You can create it using eVC's Wizard, choosing the 'WCE Pocket PC 2002 Application'.
TCHAR szCFPath [MAX_PATH+1]; // Compact Flash path
// OnCardInsert
//
// The compact flash card has been inserted
//
void OnCardInsert()
{
//
// Get the path from where we are starting up
//
if(!SHGetAutoRunPath(szCFPath))
{
return;
}
}
// OnCardRemove
//
// The compact flash card has been removed
//
void OnCardRemove()
{
}
// WinMain
//
// Main entry point
//
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
if(lstrcmpi(lpCmdLine, _T("install")) == 0)
{
//
// Card has been inserted
//
OnCardInsert();
}
else if(lstrcmpi(lpCmdLine, _T("uninstall")) == 0)
{
//
// Card has been removed
//
OnCardRemove();
}
return 0;
}
Note that your application does not know where it is starting. You cannot infer that the startup path will be the one you are expecting.
Related resources:
[출처]
http://www.pocketpcdn.com/articles/autorun.html
반응형
'Dev > Mobile' 카테고리의 다른 글
PDA 가로보기, 세로보기 전환 (Landscape, Portrait) (0) | 2006.02.09 |
---|---|
How To Use CeRapiInvoke (0) | 2005.09.13 |
WinCE에서 폰트 설치 및 삭제 (0) | 2005.03.02 |
CF기반에서 c#코딩한 소스 봤습니다. 질문좀 드릴께요 (1) | 2004.10.19 |
Dialog 창이 전체 화면에 뿌려지는것을 막고 싶습니다 (0) | 2004.01.28 |