2

服务 StillImage 中的应用程序注册

操作系统 – Windows XP SP3 编程环境 – Delphi 2010

我做了接口模块:

unit StillImage;

interface

uses
  Windows;


const
  STI_VERSION = $00000002;

type
  IStillImageW = interface(IUnknown)
    ['{641BD880-2DC8-11D0-90EA-00AA0060F86C}']
    .......
      function RegisterLaunchApplication(AppName, CommandLine: LPWSTR): HRESULT; stdcall;
    .......
  end;

  PIStillImageW = ^IStillImageW;


function StiCreateInstanceW(hinst: HINST; dwVer: DWORD; ppSti: PIStillImageW; punkOuter: IUnknown): HResult; stdcall; external 'sti.dll' name 'StiCreateInstanceW';

implementation
end.

我尝试调用一个方法 StiCreateInstanceW:

var
  Still_Image: IStillImageW;
  H_Res: HResult;
  pwszAppName: PWideChar;
  pwszCommandLine: PWideChar;
  wszAppName: array[0..1000] of WideChar;
  wszCommandLine: array[0..1000] of WideChar;
  ........

begin
  ........
  H_Res := StiCreateInstanceW(GetModuleHandle(nil), STI_VERSION, @Still_Image, nil);
  if H_Res <> S_OK then raise ...............


  FillChar(wszAppName, SizeOf(wszAppName), 0);
  FillChar(wszCommandLine, SizeOf(wszCommandLine), 0);

  pwszAppName     := StringToWideChar('Calculator', @wszAppName, SizeOf(wszAppName)-1);
  pwszCommandLine := StringToWideChar('c:\WINDOWS\system32\calc.exe', @wszCommandLine, SizeOf(wszCommandLine)-1);

  H_Res := 0;
  H_Res := Still_Image.RegisterLaunchApplication(pwszAppName, pwszCommandLine);
  if H_Res <> S_OK then raise ...............
  ...............
  ...............

结果我得到:

H_Res = 0x80070057

这意味着:(E_INVALIDARG一个或多个参数无效)

或者:STIERR_INVALID_PARAM

我所做的一切都完全按照这里写的:

http://msdn.microsoft.com/en-us/library/windows/desktop/cc836550%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/hardware /ff543798%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/cc836552%28v=vs.85%29.aspx

我尝试了以下几行:

'c:\WINDOWS\system32\calc.exe'
'"c:\WINDOWS\system32\calc.exe"'
'\"c:\WINDOWS\system32\calc.exe\"'
'c:\\WINDOWS\\system32\\calc.exe'
'\"c:\\WINDOWS\\system32\\calc.exe\"'

没有不同。

总是出错 - E_INVALIDARG/STIERR_INVALID_PARAM

4

0 回答 0