Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VarSetCapacity #32

Open
ysquare opened this issue Jan 4, 2023 · 2 comments
Open

VarSetCapacity #32

ysquare opened this issue Jan 4, 2023 · 2 comments

Comments

@ysquare
Copy link

ysquare commented Jan 4, 2023

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

@huhuime
Copy link

huhuime commented Apr 14, 2023

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
}

@mmikeww
Copy link
Owner

mmikeww commented Apr 14, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants