Application registration in service StillImage
-
Operating system – Windows XP SP3 Programming environment – Delphi 2010 I made the interface module:
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.I try to call a method 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 ...............
...............
...............As a result I get: H_Res = 0x80070057 This means: E_INVALIDARG (One or more arguments are invalid) or: STIERR_INVALID_PARAM I did everything exactly as written here: 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 I've tried the following lines:
'c:\WINDOWS\system32\calc.exe'
'"c:\WINDOWS\system32\calc.exe"'
'\"c:\WINDOWS\system32\calc.exe\"'
'c:\\WINDOWS\\system32\\calc.exe'
'\"c:\\WINDOWS\\system32\\calc -
Operating system – Windows XP SP3 Programming environment – Delphi 2010 I made the interface module:
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.I try to call a method 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 ...............
...............
...............As a result I get: H_Res = 0x80070057 This means: E_INVALIDARG (One or more arguments are invalid) or: STIERR_INVALID_PARAM I did everything exactly as written here: 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 I've tried the following lines:
'c:\WINDOWS\system32\calc.exe'
'"c:\WINDOWS\system32\calc.exe"'
'\"c:\WINDOWS\system32\calc.exe\"'
'c:\\WINDOWS\\system32\\calc.exe'
'\"c:\\WINDOWS\\system32\\calcI don't know Delphi, but I think your third parameter is incorrect, it should be the address of a pointer, and I think you have the address of a variable. In C/C++ it would be:
IStillImageW* pStill_Image;
hRes = StiCreateInstance(GetModuleHandle(NULL), STI_VERSION, &pStill_Image, NULL);which would be something like this in Delphi:
pStill_Image: PIStillImageW; // no idea if this is correct syntax
H_Res := StiCreateInstanceW(GetModuleHandle(nil), STI_VERSION, @pStill_Image, nil);NB there is also a Delphi forum just above this one; see the Treeview at left.
Veni, vidi, abiit domum