Results 1 to 5 of 5

Thread: Read Registry Dword Value

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Read Registry Dword Value

    Hello;
    i have a code.For Read Dword registry Value..

    If lDataTypeValue = REG_DWORD Then
    td = Asc(Mid$(sValue, 1, 1)) + &H100& * Asc(Mid$(sValue, 2, 1)) + &H10000 * Asc(Mid$(sValue, 3, 1)) + &H1000000 * CDbl(Asc(Mid$(sValue, 4, 1)))
    sValue = Format$(td, "000")
    End If

    And its working,But maximum chars = 3 , i need 5 chars.

    Name:  RDPPort.png
Views: 55
Size:  860 Bytes

    Thank you....
    Attached Files Attached Files

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: Read Registry Dword Value

    Value = 0
    Attached Images Attached Images  

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: Read Registry Dword Value

    Oh thank you.
    You created a spark in my head

    i Changed ==> sValue = Left$(sValue, lValueLength - 1) to sValue = Left$(sValue, lValueLength - 0)
    Worked

    If lDataTypeValue = REG_DWORD Then
    td = Asc(Mid$(sValue, 1, 1)) + &H100& * Asc(Mid$(sValue, 2, 1)) + &H10000 * Asc(Mid$(sValue, 3, 1)) + &H1000000 * CDbl(Asc(Mid$(sValue, 4, 1)))
    sValue = Format$(td, "000")
    End If
    If lDataTypeValue = REG_BINARY Then
    ' Return a binary field as a hex string (2 chars per byte)
    TStr2 = ""
    For i = 1 To lValueLength
    TStr1 = Hex(Asc(Mid(sValue, i, 1)))
    If Len(TStr1) = 1 Then TStr1 = "0" & TStr1
    TStr2 = TStr2 + TStr1
    Next
    sValue = TStr2
    Else
    sValue = Left$(sValue, lValueLength - 0)
    End If
    Else
    sValue = "Port Tanımlı Değil"
    End If
    Attached Images Attached Images  

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    2,967

    Re: Read Registry Dword Value

    My bad, now I understand what's going on here.

    You've somehow stuffed a 4-byte integer into a string, probably using a wrong API function declaration and now you have to get yourself out the corner.

    CopyMemory is your friend like this

    Call CopyMemory(td, ByVal sValue, 4)


    . . . in one direction and then in other it's like this

    sValue = Space$(4)
    Call CopyMemory(ByVal sValue, td, 4)


    Best would be to fix your RegQueryValue API declare though, using As Any for data-type agnostic parameters like this

    Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long


    cheers,
    </wqw>

Posting Permissions

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



Click Here to Expand Forum to Full Width