Ah!. (Just got back). That error message may be because of the way the RegCreateKeyEx API is declared. The 7th parameter may be declared as "lpSecurityAttributes as SECURITY_ATTRIBUTES" - a UDT. Declaring it as a Long should stop any errors. ie:

vb Code:
  1. Public Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" _
  2.    (ByVal hkey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, _
  3.    ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, _
  4.    lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long