Windows 静态图像服务中的应用注册
静态图像服务中的应用注册 操作系统–Windows XP SP3 编程环境-Delphi 2010 我制作了接口模块:Windows 静态图像服务中的应用注册,windows,delphi,delphi-2010,Windows,Delphi,Delphi 2010,静态图像服务中的应用注册 操作系统–Windows XP SP3 编程环境-Delphi 2010 我制作了接口模块: unit StillImage; interface uses Windows; const STI_VERSION = $00000002; type IStillImageW = interface(IUnknown) ['{641BD880-2DC8-11D0-90EA-00AA0060F86C}'] ....... fu
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.
我尝试调用SticCreateInstancew方法:
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 ...............
...............
...............
这意味着:E_INVALIDARG
(一个或多个参数无效)
或:STIERR\u无效\u参数
我做的每件事都和这里写的一模一样:
我试过以下几行:
'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
不是问题所在,但对StringToWideChar
的调用会传递字节大小,并且应该传递字符长度。所有这些代码都是毫无意义的。写RegisterLaunchApplication('blah','blah')
,或者如果变量中有字符串,写RegisterLaunchApplication(PChar(str1),PChar(str2))
'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\"'