Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Posts
    2

    Question Unanswered: Get Information connection, changing password

    Hello,

    I would get informations for user when I am connecting ti DB2 database in a Visual Basic project.
    I would also change DB2 password with my program.

    How can I do for that ? do I use API functions, and what API function can make that ?

    Thank's for your response.


    Boby

  2. #2
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    Hi Boby,

    Here is a Class Module that will read the user and computer names from the registry using API calls. Be sure to check your version of Windows to make sure the API calls haven't changed.

    Option Explicit
    '
    ' API calls - public functions insulate end user from the actual API calls
    ' which are unforgiving and will crash Windows if improperly used.
    '
    ' local work variables
    '
    Const BUFFERLENGTH = 256

    Private lclBuffer As Buffer
    Private lclByteLimit As Long
    Private ldlFileLength As Long
    Private lclHandle As Long
    Private lclIndex As Long
    Private lclReturn As Long
    Private lclSize As Long
    Private lclString As String

    Private Type Buffer
    cBytes(BUFFERLENGTH) As Byte
    End Type
    '
    ' get computername from registry
    '
    Private Declare Function GetComputerName _
    Lib "kernel32" Alias "GetComputerNameA" _
    (ByVal lpBuffer As String, nSize As Long) As Long
    '
    ' get username from registry
    '
    Private Declare Function GetUserName _
    Lib "advapi32.dll" Alias "GetUserNameA" _
    (ByVal lpBuffer As String, nSize As Long) As Long
    '
    ' get computername
    '
    Public Function APIGetComputerName() As String
    APIStringSetup
    lclReturn = GetComputerName(lclString, lclSize)
    APIGetComputerName = APIToVBString(lclString)

    End Function

    Public Function APIGetUserName() As String
    '
    ' get username
    '
    APIStringSetup
    lclReturn = GetUserName(lclString, lclSize)
    APIGetUserName = APIToVBString(lclString)

    End Function
    '
    ' local functions / subroutines
    '
    Private Sub APIStringSetup()
    '
    ' prepare string length and contents for API calls
    '
    lclString = Space(255)
    lclSize = Len(lclString)

    End Sub

    Private Function APIToVBString(tmpAPIString As String) As String
    '
    ' convert API string to VB string
    '
    lclSize = InStr(tmpAPIString, Chr$(0))
    If lclSize > 0 Then
    APIToVBString = Trim$(Left$(tmpAPIString, lclSize - 1))
    Else
    APIToVBString = Trim$(tmpAPIString)
    End If

    End Function

    Good Luck,
    Bruce Baasch

  3. #3
    Join Date
    Nov 2002
    Posts
    2
    Hi Bruce,

    many thanks for your response. it will help me

    But, how can i do for change DB2 password thrue VB ?

    kinds regards

    Boby

  4. #4
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    Hi Boby,

    Sorry, I've never heard of anyone doing that.
    Bruce Baasch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •