Windows ActiveX Extension Creation for GameMaker Studio pt. 2: NS Installer

Status
Not open for further replies.

Samuel Venable

Time Killer
Previous Tutorial: ActiveX DLL
GM Version: GMS 1.x / GMS 2.x
Target Platform: Windows
Required Extension: [link]
Difficulty: Advanced


USE HIGHEST QUALITY (720p) SETTING

[Files used in this video]

Software you will need for this tutorial:
  • GameMaker Studio 1.x Standard/Pro/Master Collection or GameMaker Studio 2.x Desktop Edition
  • [Optional] Microsoft Visual Basic/Studio 5.x Pro/Enterprise or Microsoft Visual Basic/Studio 6.x Pro/Enterprise
  • My *free* Microsoft Script Control Extension from the GameMaker Marketplace

Languages you will need to be somewhat familiar with how to write:
  • GameMaker Language
  • [Optional] Visual Basic 5 or Visual Basic 6
  • Visual Basic Script
  • Java Script
  • NSIS Installer Script

What programming languages can I use to create an ActiveX DLL?
  • Visual Basic 5
  • Visual Basic 6
  • Visual Basic .NET
  • Pascal
  • Delphi
  • C++ (MFC)
  • C# .NET
  • and more

Code snippets used in video:

GML/VBScript/JScript code:
Code:
if (ProgIDExists('TutorialExample.TutorialExampleCtrl') == true) {

    show_message('2 + 2 = ' + EvaluateExpression('Result', '
 
        Set objTest = CreateObject("TutorialExample.TutorialExampleCtrl")
        Result = objTest.AddNumbers(2, 2)
 
    ', "VBScript"));
 
    show_message('"Hello " + "World!" = "' + EvaluateExpression('Result', '
 
        var objTest = new ActiveXObject("TutorialExample.TutorialExampleCtrl");
        Result = objTest.AddStrings("Hello ", "World!");
 
    ', "JScript") + '"');
 
    game_end();
 
} else {

    show_message("Error! The applicarion was not installed properly.#" +
    "Please reinstall the application and try again.");
 
    game_end();

}
NSIS Installer Script code:
Code:
; RunnerInstaller.nsi
;
; This script is based on example1.nsi, but it remember the directory,
; has uninstall support and (optionally) installs start menu shortcuts.
;
; It will install example2.nsi into a directory that the user selects,

;--------------------------------
!include MUI2.nsh

!ifndef FULL_VERSION
!define FULL_VERSION      "1.0.0.0"
!endif
!ifndef SOURCE_DIR
!define SOURCE_DIR        "C:\source\temp\InstallerTest\runner"
!endif
!ifndef INSTALLER_FILENAME
!define INSTALLER_FILENAME    "C:\source\temp\InstallerTest\RunnerInstaller.exe"
!endif

!ifndef MAKENSIS
!define MAKENSIS          "%appdata%\GameMaker-Studio\makensis"
!endif

!ifndef COMPANY_NAME
!define COMPANY_NAME      ""
!endif

!ifndef COPYRIGHT_TXT
!define COPYRIGHT_TXT     "(c)Copyright 2013"
!endif

!ifndef FILE_DESC
!define FILE_DESC         "Created with GameMaker:Studio"
!endif

!ifndef LICENSE_NAME
!define LICENSE_NAME      "License.txt"
!endif

!ifndef ICON_FILE
!define ICON_FILE       "icon.ico"
!endif

!ifndef IMAGE_FINISHED
!define IMAGE_FINISHED      "Runner_finish.bmp"
!endif

!ifndef IMAGE_HEADER
!define IMAGE_HEADER      "Runner_header.bmp"
!endif

!ifndef PRODUCT_NAME
!define PRODUCT_NAME      "Runner"
!endif

!define APP_NAME        "${PRODUCT_NAME}"
!define SHORT_NAME        "${PRODUCT_NAME}"

!ifndef EXE_NAME
!define EXE_NAME "${PRODUCT_NAME}"
!endif


;;USAGE:
!define MIN_FRA_MAJOR "2"
!define MIN_FRA_MINOR "0"
!define MIN_FRA_BUILD "*"

!addplugindir   "."

;--------------------------------

; The name of the installer
Name "${APP_NAME}"
Caption "${APP_NAME}"
BrandingText "${APP_NAME}"

; The file to write
OutFile "${INSTALLER_FILENAME}"

; The default installation directory
InstallDir "$PROFILE\${APP_NAME}"

; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKCU "Software\Runner" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin


VIProductVersion "${FULL_VERSION}"
VIAddVersionKey /LANG=1033 "FileVersion" "${FULL_VERSION}"
VIAddVersionKey /LANG=1033 "ProductVersion" "${FULL_VERSION}"
VIAddVersionKey /LANG=1033 "ProductName" "${PRODUCT_NAME}"
VIAddVersionKey /LANG=1033 "CompanyName" "${PRODUCT_PUBLISHER}"
VIAddVersionKey /LANG=1033 "LegalCopyright" "${COPYRIGHT_TXT}"
VIAddVersionKey /LANG=1033 "FileDescription" "${FILE_DESC}"



!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_ICON            "${ICON_FILE}"
!define MUI_WELCOMEFINISHPAGE_BITMAP  "${IMAGE_FINISHED}"
!define MUI_HEADERIMAGE_BITMAP      "${IMAGE_HEADER}"
!define MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH


;--------------------------------

; Pages
!insertmacro MUI_PAGE_LICENSE "${LICENSE_NAME}"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
    # These indented statements modify settings for MUI_PAGE_FINISH
    !define MUI_FINISHPAGE_NOAUTOCLOSE
    !define MUI_FINISHPAGE_RUN_TEXT "Start ${PRODUCT_NAME}"
    !define MUI_FINISHPAGE_RUN "$INSTDIR\${EXE_NAME}.exe"
!insertmacro MUI_PAGE_FINISH

Var DirectXSetupError

UninstPage uninstConfirm
UninstPage instfiles

!insertmacro MUI_LANGUAGE "English"
;--------------------------------

; The stuff to install
Section `${APP_NAME}`
  SectionIn RO
 
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
 
  ; Put file there
  File "${LICENSE_NAME}"
  File /r "${SOURCE_DIR}\*.*"

  ; Install VB5 runtime
  ExecWait "$INSTDIR\msvbvm50.exe"

  ; Register ActiveX controls
  RegDLL "$INSTDIR\TutorialExample.dll"
 
  ; Write the uninstall keys for Windows
  WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}" "DisplayName" "${APP_NAME}"
  WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}" "NoModify" 1
  WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}" "NoRepair" 1
  WriteUninstaller "uninstall.exe"

SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\${APP_NAME}"
  CreateShortCut "$SMPROGRAMS\${APP_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${EXE_NAME}.exe" "" "$INSTDIR\${EXE_NAME}.exe"
  CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME} License.lnk" "notepad.exe" "$INSTDIR\License.txt"
 
SectionEnd


; Optional section (can be enabled by the user)
Section /o "Desktop shortcut"

  CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${EXE_NAME}.exe" ""
 
SectionEnd


;--------------------------------

; Uninstaller

Section "Uninstall"
  ; Remove registry keys
  DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}"

  ; Unregister ActiveX controls
  UnRegDLL "$INSTDIR\TutorialExample.dll"

  ; Remove files and uninstaller (everything)
  RMDir /r "$INSTDIR"

  ; Remove desktop icon
  Delete "$DESKTOP\${APP_NAME}.lnk"

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\${APP_NAME}\*.*"

  ; Remove directories used
  RMDir "$SMPROGRAMS\${APP_NAME}"
  RMDir "$INSTDIR"

SectionEnd


;--------------------------------
;
; This should be the LAST section available....
;
Section "DirectX Install" SEC_DIRECTX
 
 SectionIn RO
 
 SetOutPath "$TEMP"
 File "${MAKENSIS}\dxwebsetup.exe"
 DetailPrint "Running DirectX Setup..."
 ExecWait '"$TEMP\dxwebsetup.exe" /Q' $DirectXSetupError
 DetailPrint "Finished DirectX Setup"
 
 Delete "$TEMP\dxwebsetup.exe"
 
 SetOutPath "$INSTDIR"
 
SectionEnd
 
Last edited:
Status
Not open for further replies.
Top