在U盘上运行a.exe(以下为它的代码),在b.exe没有退出的进候,可以删除U盘上的a.exe, 但不能停用U盘,当b.exe退出的时候可以停用U盘。请问如何实现在不退出b.exe的情况下停用U盘。#include <shellapi.h>int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
ShellExecute(NULL, NULL, "c:\\b.exe", "aa", NULL, SW_SHOWNORMAL);
return 1;
}

解决方案 »

  1.   

    HINSTANCE ShellExecute(          HWND hwnd,
        LPCTSTR lpOperation,
        LPCTSTR lpFile,
        LPCTSTR lpParameters,
        LPCTSTR lpDirectory,
        INT nShowCmd
    );lpParameters
    [in] If the lpFile parameter specifies an executable file, lpParameters is a pointer to a null-terminated string that specifies the parameters to be passed to the application. The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.参数“aa”有什么作用?!
    改为null试试。
      

  2.   

    谢谢大家的关注,这个问题已解决。 只需在调用ShellExecute之前更改当前路径, 即调用SetCurrentDirectory("C;\\")。