v1 UseGDIP:
Code: Select all
UseGDIP(Params*) { ; Loads and initializes the Gdiplus.dll at load-time
; GET_MODULE_HANDLE_EX_FLAG_PIN = 0x00000001
Static GdipObject := ""
, GdipModule := ""
, GdipToken := ""
Static OnLoad := UseGDIP()
If (GdipModule = "") {
If !DllCall("LoadLibrary", "Str", "Gdiplus.dll", "UPtr")
UseGDIP_Error("The Gdiplus.dll could not be loaded!`n`nThe program will exit!")
If !DllCall("GetModuleHandleEx", "UInt", 0x00000001, "Str", "Gdiplus.dll", "PtrP", GdipModule, "UInt")
UseGDIP_Error("The Gdiplus.dll could not be loaded!`n`nThe program will exit!")
VarSetCapacity(SI, 24, 0), NumPut(1, SI, 0, "UInt") ; size of 64-bit structure
If DllCall("Gdiplus.dll\GdiplusStartup", "PtrP", GdipToken, "Ptr", &SI, "Ptr", 0)
UseGDIP_Error("GDI+ could not be startet!`n`nThe program will exit!")
GdipObject := {Base: {__Delete: Func("UseGDIP").Bind(GdipModule, GdipToken)}}
}
Else If (Params[1] = GdipModule) && (Params[2] = GdipToken)
DllCall("Gdiplus.dll\GdiplusShutdown", "Ptr", GdipToken)
}
UseGDIP_Error(ErrorMsg) {
MsgBox, 262160, UseGDIP, %ErrorMsg%
ExitApp
}
v2 UseGDIP:
Code: Select all
UseGDIP()
UseGDIP(Params*) { ; Loads and initializes the Gdiplus.dll at load-time
; GET_MODULE_HANDLE_EX_FLAG_PIN = 0x00000001
Static GdipObject := Object(),
GdipModule := 0,
GdipToken := 0
If (GdipModule = 0) {
If !DllCall("LoadLibrary", "Str", "Gdiplus.dll", "UPtr")
UseGDIP_Error("The Gdiplus.dll could not be loaded!`n`nThe program will exit!")
If !DllCall("GetModuleHandleEx", "UInt", 0x00000001, "Str", "Gdiplus.dll", "PtrP", &GdipModule, "UInt")
UseGDIP_Error("The Gdiplus.dll could not be loaded!`n`nThe program will exit!")
SI := Buffer(24, 0) ; size of 64-bit structure
NumPut("UInt", 1, SI)
If DllCall("Gdiplus.dll\GdiplusStartup", "PtrP", &GdipToken, "Ptr", SI, "Ptr", 0, "UInt")
UseGDIP_Error("GDI+ could not be startet!`n`nThe program will exit!")
GdipObject := {__Delete: UseGDIP.Bind(GdipModule, GdipToken)}
MsgBox(GdipModule . " - " . GdipToken, A_ThisFunc)
}
Else If (Params[1] = GdipModule) && (Params[2] = GdipToken)
DllCall("Gdiplus.dll\GdiplusShutdown", "Ptr", GdipToken)
}
UseGDIP_Error(ErrorMsg) {
MsgBox(ErrorMsg, "UseGDIP", 262160)
ExitApp
}
Code: Select all
---------------------------
UseGDIP.ahk
---------------------------
Error: This variable has not been assigned a value.
Specifically: static GdipModule
Line#
001: UseGDIP()
003: {
---> 008: If (GdipModule = 0)
008: {
009: If !DllCall("LoadLibrary", "Str", "Gdiplus.dll", "UPtr")
010: UseGDIP_Error("The Gdiplus.dll could not be loaded!
The program will exit!")
011: If !DllCall("GetModuleHandleEx", "UInt", 0x00000001, "Str", "Gdiplus.dll", "PtrP", &GdipModule, "UInt")
012: UseGDIP_Error("The Gdiplus.dll could not be loaded!
The program will exit!")
013: SI := Buffer(24, 0)
014: NumPut("UInt", 1, SI)
Try to continue anyway?
---------------------------
Ja Nein
---------------------------