pinvoke RegFlushKey

G

Guest

I am having problems pinvoking the RegFlushKey function to flush my Hive registry, i keep getting a System.NotSupported Exception when i call it. Am i doing something wrong? Here is the code

Const HKEY_LOCAL_MACHINE = &H8000000
Private Declare Function RegFlushKey Lib "coredll.dll" (ByVal hKey As Long) As Lon

dim r as Long = RegFlushKey(HKEY_LOCAL_MACHINE)
 
P

Paul G. Tobey [eMVP]

I'm not sure what the problem is. It *is* in coredll.dll.

Paul T.

Dante said:
I am having problems pinvoking the RegFlushKey function to flush my Hive
registry, i keep getting a System.NotSupported Exception when i call it. Am
i doing something wrong? Here is the code:
 
P

Peter Foot [MVP]

In .net the hKey and return value are 32bit Integers:-
Private Declare Function RegFlushKey Lib "coredll.dll" (ByVal hKey As
Integer) As Integer

A Long is a 64bit integer and cannot be marshalled by value.

Peter
 
P

Paul G. Tobey [eMVP]

Of course! Both the parameter and the return value types are wrong. Nice
catch!

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top