AHKv2-Gdip icon indicating copy to clipboard operation
AHKv2-Gdip copied to clipboard

VarSetCapacity

Open ysquare opened this issue 2 years ago • 2 comments

VarSetCapacity is no longer available in ahk v2.0 release, replaced by Buffer() according to the document.

ysquare avatar Jan 04 '23 13:01 ysquare

example

Gdip_Startup()
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	pToken := 0

	if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
		DllCall("LoadLibrary", "str", "gdiplus")
	VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
	DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", pToken, Ptr, &si, Ptr, 0)
	return pToken
}

replace

Gdip_Startup()
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	pToken := 0

	if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
		DllCall("LoadLibrary", "str", "gdiplus")
	;VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
	si := Buffer(A_PtrSize = 8 ? 24 : 16, 0)
	NumPut("int", 1, si.Ptr)
	DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", &pToken, Ptr, si.Ptr, Ptr, 0)
	return pToken
}

huhuime avatar Apr 14 '23 13:04 huhuime

The problem is that this library was meant to be backwards compatible to work on both v1 and v2...

mmikeww avatar Apr 14 '23 18:04 mmikeww