read byte via DllCall

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

read byte via DllCall

29 Nov 2018, 19:15

- I was curious as to whether there was a Winapi function that simply returns the value of a byte/a stream of bytes.
- I was looking at recreating NumGet and NumPut via DllCall.
- This function uses *, the dereference operator, to do NumGet, although that operator won't be available in AHK v2.
Choose naming and syntax for built-in Extract/InsertInteger - Page 2 - Suggestions - AutoHotkey Community ... ntry118402
- Here's a bit of test code.

Code: Select all

q:: ;recreate NumPut
vText := "abc"
if A_IsUnicode
	DllCall("ntdll\RtlFillMemory", Ptr,&vText+2, UPtr,1, UChar,Ord("B"))
	, DllCall("ntdll\RtlFillMemory", Ptr,&vText+3, UPtr,1, UChar,0)
	DllCall("ntdll\RtlFillMemory", Ptr,&vText+1, UPtr,1, UChar,Ord("B"))
MsgBox, % vText

w:: ;recreate NumGet (without using the dereference operator *)
vText := "abc"
VarSetCapacity(vData, 4, 0)
DllCall("kernel32\RtlMoveMemory", Ptr,&vData, Ptr,&vText, UPtr,1)
MsgBox, % Ord(vData)

e:: ;recreate NumGet (without using the dereference operator *)
vText := "abc"
MsgBox, % Ord(StrGet(&vText, "CP0"))
MsgBox, % Ord(StrGet(&vText+1, "CP0"))
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Posts: 4693
Joined: 17 Jul 2016, 01:02

Re: read byte via DllCall

30 Nov 2018, 09:04

Hello, I made this a puzzle.


Return to “Ask for Help”

Who is online

Users browsing this forum: crocodile, DrReflex, jNizM, PepeLapiu, QyouLimYT, Rohwedder and 50 guests