1. Roland Smith
  2. PowerBuilder
  3. Friday, 24 August 2018 15:42 PM UTC

I need to be able to get the user's SID (session id) in string form, for example: S-1-5-5-0-687862401.

I need to access registry info under:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\

I'm trying to use the API function LookupAccountName but having no luck. My thinking was to follow that by a call to ConvertSidToStringSid.

 

Roland Smith Accepted Answer Pending Moderation
  1. Friday, 24 August 2018 18:47 PM UTC
  2. PowerBuilder
  3. # 1
I'm going with this pure PB code unless a simple API call is found:

Long ll_idx, ll_max
String ls_RegKey, ls_SubKey[], ls_GetKey, ls_Device

ls_RegKey = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows"

ls_GetKey = ls_RegKey + "\SessionDefaultDevices"
RegistryKeys(ls_GetKey, ls_SubKey)

ll_max = UpperBound(ls_SubKey)
If ll_max = 0 Then
RegistryGet(ls_RegKey, "Device", RegString!, ls_Device)
Else
For ll_idx = 1 To ll_max
ls_GetKey = ls_RegKey + "\SessionDefaultDevices\" + ls_SubKey[ll_idx]
RegistryGet(ls_GetKey, "Device", RegString!, ls_Device)
If ls_Device <> "" Then Exit
Next
End If
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.