Installer?!

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

Brauchste nur die vorletzte Zeile anpassen. Hier der Code (Auszug aus TS-Shutdown :D ) :

Code: Alles auswählen

#CSIDL_STARTUP   =  7

Structure EMID
  cb.b
  abID.b[1]
EndStructure

Structure ITEMIDLIST
  mkid.EMID
EndStructure

Procedure.s myGetSpecialeFolder(Folder.l)
  *itemid.ITEMIDLIST = #Null
  If SHGetSpecialFolderLocation_ (0, Folder, @*itemid) = #NOERROR
    location.s = Space (#MAX_PATH)
    If SHGetPathFromIDList_ (*itemid, @location)
      If Right(location, 1) <> "\" : location + "\" : EndIf
      ProcedureReturn location
    EndIf
  EndIf
EndProcedure

Procedure myCreateShortcut(Path.s, Link.s, WorkingDir.s, Argument.s, IconFile.s, IconIndex.l)
  ShowCommand = #SW_SHOWNORMAL
  Description.s = ""
  HotKey = #Null
  CoInitialize_(0)
  If CoCreateInstance_(?CLSID_ShellLink,0,1,?IID_IShellLink,@psl.IShellLinkA) = 0
    Set_ShellLink_preferences:
    psl\SetPath(@Path)
    psl\SetArguments(@Argument)
    psl\SetWorkingDirectory(@WorkingDir)
    psl\SetDescription(@Description)
    psl\SetShowCmd(ShowCommand)
    psl\SetHotkey(HotKey)
    psl\SetIconLocation(@IconFile, IconIndex)
    ShellLink_SAVE:
    If psl\QueryInterface(?IID_IPersistFile,@ppf.IPersistFile) = 0
      mem.s = Space(1000)
      MultiByteToWideChar_(#CP_ACP, 0, Link, -1, mem, 1000)
      hres = ppf\Save(@mem,#True)
      Result = 1
      ppf\Release()
    EndIf
    psl\Release()
  EndIf
  CoUninitialize_()
  ProcedureReturn Result
  DataSection
  CLSID_ShellLink:
  Data.l $00021401
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
  IID_IShellLink:
  Data.l $000214EE
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
  IID_IPersistFile:
  Data.l $0000010B
  Data.w $0000,$0000
  Data.b $C0,$00,$00,$00,$00,$00,$00,$46
  EndDataSection
EndProcedure

Procedure.s GetFullPath()
  FullPath.s = Space(#MAX_PATH)
  GetModuleFileName_(GetModuleHandle_(0), @FullPath, #MAX_PATH)
  FullPath = GetPathPart(FullPath)
  If Right(FullPath, 1) <> "\"
    FullPath = FullPath + "\"
  EndIf
  ProcedureReturn FullPath
EndProcedure

MeinProgramm.s = "Tolles Programm" ; Programmname ohne Extension
myCreateShortcut(GetFullPath() + MeinProgramm.s + ".exe", myGetSpecialeFolder(#CSIDL_STARTUP) + "\" + MeinProgramm.s + ".lnk", "", "",GetFullPath() + MeinProgramm.s, 0)
Am besten ins private Code-Archiv damit oder als Template für die neue IDE :)

PS: Teilweise angepaßte Codes aus dem CodeArchiv, besonders die Prozedure zum erstellen eines Shortcuts stammt von Danilo :)
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
satzzeichen
Beiträge: 34
Registriert: 22.05.2005 13:59
Wohnort: Rötha bei Leipzig
Kontaktdaten:

Beitrag von satzzeichen »

Leute es ging doch nur um nen Installer der rest ist doch schon fertig!

Also danke nochmal für das Nisis Ding :)
Der erhabene Geist schafft am meisten, wenn er am wenigsten Arbeitet. Leonardo da Vinci

Ich hätte nie gedacht, dass es soviele Fette gibt. Da kann man ja noch was lernen. G. Schröder
Antworten