SHGetAutoRunPath的说明及用法(未验证)

MSDN的说明:

This function will search for the first storage card and construct the path that is used to look for an autorun file. The autorun file and directory do not need to be present on the storage card, but a storage card must be inserted for this function to succeed.

Syntax
BOOL SHGetAutoRunPath(
  LPTSTR pAutoRunPath
);
Parameters
pAutoRunPath
[out] Pointer to a user-allocated string allocated to at least MAX_PATH characters. If successful, the full path name to the autorun directory will be copied here (for example, /Storage Card 1/2577/autorun.exe).
Return Values

Returns TRUE if a path was successfully constructed and copied to pAutoRunPath. Returns FALSE if a path could not be copied. FALSE indicates that either the input parameter is invalid or a storage card is not currently inserted.

Remarks

This function returns a string in the form /Storage Card 1/2577/autorun.exe. The operating system (OS) looks for the file autorun.exe in an appropriate subdirectory, which should be named using the microprocessor ID number found in Winnt.h. The following table shows microprocessor IDs for some common microprocessor families.

Microprocessor familyMicroprocessor ID
All x86 microprocessors486
MIPS II/MIPS324000
MIPS IV/MIPS645000
SH410005

You can call GetSystemInfo to determine the microprocessor type and architecture for your device.

Windows Mobile Remarks

The following table provides processor values for each of the supported processor types.

CPU nameCPU type value
SH310003
MIPS4000
ARM (SA1100)2577
ARM (720)1824
x86686

In addition, if autorun.exe is not found in the processor-specific subdirectory, SHGetAutoRunPath will return /<Storage Card>/0/autorun.exe, which indicates a special processor type of 0 for a CEF executable. For example, if the storage card contained 4000/autorun.exe and 0/autorun.exe, the executable file in 4000/ would be run on a MIPS device; on an SH3 device, the executable file in 0/ would be run. As with the old name-based implementation, you may make these folders hidden to avoid cluttering up the folder view in applications like the File Explorer.

After autorun.exe begins to run, it is sometimes useful for it to know which directory it is running from. Autorun.exe can then determine how to manage files or take actions based on its location in the system.

Requirements

OS Versions: Windows CE .NET 4.2 and later
Header: windows.h.
Library: aygshell.lib

Windows Mobile Requirements

Pocket PC: Pocket PC 2000 and later
Smartphone: Smartphone 2002 and later
OS Versions: Windows CE 3.0 and later
Header: aygshell.h
Library: aygshell.lib

 

===================================================================

用法:

QA: How to implement autorun from a storage card?
February 1st, 2005 by Joao Paulo Figueira

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.

     

    http://windowsmobiledn.com/qa-how-to-implement-autorun-from-a-storage-card/

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 、4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合;、下载 4使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合;、 4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.m或d论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 、1资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。、资源 5来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。、资 5源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值