各位大侠好小弟最近在Vista系统下使用ShellExecute函数启动另外一个程序的时候遇到了一个问题,如下:就是启动同一个程序,有的时候成功,有的时候失败,不知道是什么原因,这里高手如云,请给位指教。ps 查了很多资料,都说是UAC引起的,但为什么有时候还能成功呢?
   同样的程序在XP和win7下都没问题,唯独Vista。谢谢。

解决方案 »

  1.   

    对照返回值看看.Return ValueReturns a value greater than 32 if successful, or an error value that is less than or equal to 32 otherwise. The following table lists the error values. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. The only thing that can be done with the returned HINSTANCE is to cast it to an int and compare it with the value 32 or one of the error codes below.0 The operating system is out of memory or resources. 
    ERROR_FILE_NOT_FOUND The specified file was not found. 
    ERROR_PATH_NOT_FOUND The specified path was not found. 
    ERROR_BAD_FORMAT The .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image). 
    SE_ERR_ACCESSDENIED The operating system denied access to the specified file. 
    SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid. 
    SE_ERR_DDEBUSY The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed. 
    SE_ERR_DDEFAIL The DDE transaction failed. 
    SE_ERR_DDETIMEOUT The DDE transaction could not be completed because the request timed out. 
    SE_ERR_DLLNOTFOUND The specified dynamic-link library (DLL) was not found. 
    SE_ERR_FNF The specified file was not found. 
    SE_ERR_NOASSOC There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable. 
    SE_ERR_OOM There was not enough memory to complete the operation. 
    SE_ERR_PNF The specified path was not found. 
    SE_ERR_SHARE A sharing violation occurred. 
      

  2.   

    恩,看看ShellExecute函数的返回值是多少
      

  3.   

    vista运行程序貌似要获得管理员权限,不会是这原因吧
      

  4.   

    给你个方案:          将你的visual stduio设置为以管理员权限运行。           相关文章:http://blog.csdn.net/ywwzq0507/archive/2010/07/30/5777524.aspx
      

  5.   

    vista就别管了吧,那个是过渡的产品现在基本都在用win7了