Tema: Dns
Ver Mensaje Individual
  #6 (permalink)  
Antiguo 07/10/2008, 08:09
Avatar de mvazquez
mvazquez
 
Fecha de Ingreso: octubre-2004
Ubicación: Monterrey - México
Mensajes: 875
Antigüedad: 20 años, 4 meses
Puntos: 8
Respuesta: Dns

tengo este codigo que hice hace tiempo pero para VB6

Código:
Private Const REG_SZ = 1
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long


Public Sub CrearOdbc(DataSourceName As String, DatabaseName As String, Description As String, DriverPath As String, DriverName As String, LastUser As String, Server As String)
Dim lResult As Long
Dim hKeyHandle As Long
Dim Regional As String

   'Create the new DSN key.
    lResult = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\" & DataSourceName, hKeyHandle)  'Set the values of the new DSN key.
    
    lResult = RegSetValueEx(hKeyHandle, "Database", 0&, REG_SZ, ByVal DatabaseName, Len(DatabaseName))
    lResult = RegSetValueEx(hKeyHandle, "Description", 0&, REG_SZ, ByVal Description, Len(Description))
    lResult = RegSetValueEx(hKeyHandle, "Driver", 0&, REG_SZ, ByVal DriverPath, Len(DriverPath))
    lResult = RegSetValueEx(hKeyHandle, "LastUser", 0&, REG_SZ, ByVal LastUser, Len(LastUser))
    
    lResult = RegSetValueEx(hKeyHandle, "Server", 0&, REG_SZ, ByVal Server, Len(Server))   'Close the new DSN key.
    lResult = RegCloseKey(hKeyHandle)
    
    'Open ODBC Data Sources key to list the new DSN in the ODBC Manager.
    'Specify the new value.
    'Close the key.
    lResult = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", hKeyHandle)
    lResult = RegSetValueEx(hKeyHandle, DataSourceName, 0&, REG_SZ, ByVal DriverName, Len(DriverName))
    lResult = RegCloseKey(hKeyHandle)
End Sub
necesito crear algo similar para .Net en WinForm
__________________
http://vazquezvega.wordpress.com/
"La paciencia nos da el privilegio de compartir el refrescante fruto de Dios con los demás."