By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 1,088 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

Saving to Registry after upgrade

P: n/a
LDD
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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"LDD" <la***************@gmail.com> schrieb:
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.


How do you call the function?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2

P: n/a
LDD
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

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
"LDD" <la***************@gmail.com> schrieb:
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.


How do you call the function?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
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" <la***************@gmail.com> сообщил/сообщила в новостях
следующее: news:2L********************@magma.ca...
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

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.