Groups | Blog | Home
all groups > vb.net upgrade > september 2005 >

vb.net upgrade : Saving to Registry after upgrade



Herfried K. Wagner [MVP]
9/21/2005 12:00:00 AM
"LDD" <largedoubledouble@gmail.com> schrieb:
[quoted text, click to view]

How do you call the function?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
Dragon
9/21/2005 12:00:00 AM
Hi dude,

Your declaration seems to be OK, however I would use this one:

~
Public Declare Auto Function RegCreateKeyEx Lib "advapi32.dll" ( _
ByVal hKey As IntPtr, _
<MarshalAs(UnmanagedType.LPTStr), [In]()> ByVal lpSubKey As String,
_
ByVal Reserved As Integer, _
<MarshalAs(UnmanagedType.LPTStr)> ByVal lpClass As StringBuilder, _
ByVal dwOptions As Integer, _
ByVal samDesired As Integer, _
ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, _
ByRef phkResult As IntPtr, _
ByRef lpdwDisposition As Integer _
)
~

Anyway, this is a matter of liking.

Are you trying to pass NULL to lpSecurityAttributes? If yes, then you
should include overloaded version of your Declare statement with
lpSecurityAttributes declared as IntPtr and then pass IntPtr.Zero to it.

Error 1314 (ERROR_PRIVILEGE_NOT_HELD) means "A required privilege is not
held by the client.", so you may want to check your rights.

If it doesn't work, provide your SECURITY_ATTRIBUTES declaration please.

HTH,
Roman

"LDD" <largedoubledouble@gmail.com> ñîîáùèë/ñîîáùèëà â íîâîñòÿõ
ñëåäóþùåå: news:2LOdnaje4Iar7azeRVn-pA@magma.ca...
[quoted text, click to view]

LDD
9/21/2005 10:37:41 AM
Hey folks

I'm upgrading an existing application from VB6 to VB.Net
It's a slow painful process, and there isn't time to rewrite it.
I'm using RegCreateKeyEx(...) to save some data to the registry.
I'm getting Error 1314 and can't seem to find much useful info on this.

If anyone has any information that can help me out that would be great.
Definition:
Public Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias
"RegCreateKeyExA" (ByVal hKey As Integer, ByVal lpSubKey As String, ByVal
Reserved As Integer, ByVal lpClass As String, ByVal dwOptions As Integer,
ByVal samDesired As Integer, ByRef lpSecurityAttributes As
SECURITY_ATTRIBUTES, ByRef lphkResult As Integer, ByRef lpdwDisposition As
Integer) As Integer


Thanks folks

LDD

LDD
9/21/2005 11:22:43 AM
Here is where it gets called from.

Public Sub gSetRegParamString(ByRef rlHKey As Integer, ByRef rsSubKey As
String, ByRef rsPropertyName As String, ByRef rsPropertyValue As String)

Dim plRC As Integer
Dim plNewHKey As Integer
Dim psSubKey As String
Dim plOpenKey As Integer

'New for create key
Dim plDispositionBuffer As Integer
Dim SA As SECURITY_ATTRIBUTES

RegCreateKeyEx(HKEY_LOCAL_MACHINE, rsSubKey, 0, vbNullString,
REG_OPTION_NON_VOLATILE, KEY_WRITE, SA, plNewHKey, plDispositionBuffer)
.....

End Sub

I know it's something I'm overlooking...

LDD

[quoted text, click to view]

AddThis Social Bookmark Button