I've been looking into advapi32.dll's registry functions and have got as far as opening a key and querying the value, but of course I can't access the buffer that it puts the string into because it's in forbidden memory space. So how do I get it?
This is what I have (trying to get the path of the associated application for .NES files, but that's not important, it's just a test:)
This is what I have (trying to get the path of the associated application for .NES files, but that's not important, it's just a test:)
Strict Import "-ladvapi32" Extern "Win32" Function RegOpenKeyExA:Int(hKeyParent:Int, SubKey$z, MustBeZero:Int, AccessMask:Int, .. phkResult:Int Var) Function RegQueryValueExA( hKey:Int, .. lpValueName$z, .. MustBeNull:Int, .. DataType:Int Var, .. lpData:Byte Ptr Var, .. BufferSize:Int Var) Function RegCloseKey:Int(hKey:Int) End Extern Const HKEY_CLASSES_ROOT:Long = $80000000 Const KEY_READ = $20019 Const ERROR_SUCCESS = 0 Local nesAutoFileKey:Int If RegOpenKeyExA( HKEY_CLASSES_ROOT, "nes_auto_file\shell\open\command", .. 0, KEY_READ, nesAutoFileKey) = ERROR_SUCCESS Print "Key " + nesAutoFileKey + " opened successfully!" Local DataSize:Int = 1000 Local Data:Byte Ptr = MemAlloc(DataSize) Local DataType:Int If RegQueryValueExA( nesAutoFileKey, "", Null, DataType, Data, DataSize) = ERROR_SUCCESS Print "Value queried successfully!" Print "Data length: " + DataSize Local Stream:TStream = CreateRamStream(Data,DataSize,1,0) Print ReadLine(Stream) CloseStream(Stream) MemFree Data RegCloseKey(nesAutoFileKey) End If End If