Games to Vista Game explorer with Inno Setup

Posted by Kraemer on Game Development See other posts from Game Development or by Kraemer
Published on 2011-02-15T15:39:26Z Indexed on 2011/02/15 23:35 UTC
Read the original article Hit count: 598

Filed under:

Ok, i'm trying to force my inno setup installer to add a shortcut of my game to Vista Games Explorer. Theoretically this should do the trick:

[Files]
Source: "GameuxInstallHelper.dll"; DestDir: "{app}"; Flags: ignoreversion overwritereadonly;

[Registry]
Root: HKLM; Subkey: SOFTWARE\dir\dir; Flags: uninsdeletekeyifempty
Root: HKLM; Subkey: SOFTWARE\dir\dir; ValueName: Path; ValueType: String; ValueData: {app}; Flags: uninsdeletekey
Root: HKLM; Subkey: SOFTWARE\dir\dir; ValueName: AppFile; ValueType: String; ValueData:{app}\executable.exe ; Flags: uninsdeletekey

[CustomMessages]
en.Local=en
en.removemsg=Do you wish to remove game saves and settings?
en.taskentry=Play

[Code]
const
  PlayTask = 0;
  AllUsers = 2;
  Current = 3;

type
  TGUID = record
  Data1: Cardinal;
  Data2,
  Data3: Word;
  Data4: array [0..7] of char;
end;
var
  GUID: TGUID;

function GetDC(HWND: DWord): DWord;
external '[email protected] stdcall';
function GetDeviceCaps(DC: DWord; Index: Integer): Integer;
external '[email protected] stdcall';
function ReleaseDC(HWND: DWord;DC: DWord): Integer;
external '[email protected] stdcall';
function ShowWindow(hWnd: DWord; nCmdShow: Integer): boolean;
external '[email protected] stdcall';
function SetWindowLong(hWnd: DWord; nIndex: Integer; dwNewLong: Longint):Longint;
external '[email protected] stdcall';
function GenerateGUID(var GUID: TGUID): Cardinal;
external 'GenerateGUID@files:GameuxInstallHelper.dll stdcall setuponly';
function AddToGameExplorer(Binary: String; Path: String; InstallType: Integer; var GUID: TGUID): Cardinal;
external 'AddToGameExplorerW@files:GameuxInstallHelper.dll stdcall setuponly';
function CreateTask(InstallType: Integer; var GUID: TGUID; TaskType: Integer; TaskNumber: Integer; TaskName: String; Binary: String; Parameters: String): Cardinal;
external 'CreateTaskW@files:GameuxInstallHelper.dll stdcall setuponly';
function RetrieveGUIDForApplication(Binary: String; var GUID: TGUID): Cardinal;
external 'RetrieveGUIDForApplicationW@{app}\GameuxInstallHelper.dll stdcall uninstallonly';
function RemoveFromGameExplorer(var GUID: TGUID): Cardinal;
external 'RemoveFromGameExplorer@{app}\GameuxInstallHelper.dll stdcall uninstallonly';
function RemoveTasks(var GUID: TGUID): Cardinal;
external 'RemoveTasks@{app}\GameuxInstallHelper.dll stdcall uninstallonly';

function InitializeSetup(): Boolean;
var
  appath: string;
  ResultCode: Integer;

begin
  if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\dir\dir') then
   begin
    RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\dir\dir', 'Path', appath)
    Exec((appath +'\unins000.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
    end else
    begin
    Result := TRUE
   end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usUninstall then
  begin
    if GetWindowsVersion shr 24 > 5 then
    begin
    RetrieveGUIDForApplication(ExpandConstant('{app}\AWL_Release.dll'), GUID);
    RemoveFromGameExplorer(GUID);
    RemoveTasks(GUID);
    UnloadDll(ExpandConstant('{app}\GameuxInstallHelper.dll'));
    end;
  end;

  if CurUninstallStep = usPostUninstall then
  begin
   if MsgBox(ExpandConstant('{cm:removemsg}'), mbConfirmation, MB_YESNO)=IDYES then
     begin
      DelTree(ExpandConstant('{app}'), True, True, True);
     end;
 end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if GetWindowsVersion shr 24 > 5 then
 begin
  if CurStep = ssInstall then
    GenerateGUID(GUID);
  if CurStep = ssPostInstall then
  begin
    AddToGameExplorer(ExpandConstant('{app}\AWL_Release.dll'), ExpandConstant('{app}'), Current, GUID);
    CreateTask(3, GUID, PlayTask, 0, ExpandConstant('{cm:taskentry}'), ExpandConstant('{app}\executable.exe'), '');
    CreateTask(3, GUID, 1, 0, 'Game Website', 'http://www.gamewebsite.com/', '');
  end;
 end;
end;

The installer works just fine, but it doesn't place a shortcut of my game to Games explorer. Since i believe that the problem is on the binary file i guess for that part i should ask for some help. So, can anyone please give me a hand here?

© Game Development or respective owner

Related posts about programming