Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. Application registration in service StillImage

Application registration in service StillImage

Scheduled Pinned Locked Moved Windows API
delphivisual-studiocomhardwaredata-structures
2 Posts 2 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eKIJh
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • E eKIJh

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups