|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Current UserI am using the GetUserName API and want to know where the API looks to
retrieve the username.I know the documentation say "The GetUserName function retrieves the user name of the current thread. This is the name of the user currently logged onto the system." Ok so where does it look. Is it in the registry? if so what hive. Any help would be great. Thanks Cam "Cam" <n*@no.com> wrote in message My assumption would be that it is just in memory somewhere. The OS has anews:%23RQEx0uYFHA.2160@TK2MSFTNGP10.phx.gbl > I am using the GetUserName API and want to know where the API looks to > retrieve the username.I know the documentation say "The GetUserName > function retrieves the user name of the current thread. This is the > name of the user currently logged onto the system." > Ok so where does it look. Is it in the registry? if so what hive. > Any help would be great. list of active threads with all associated information that it needs to keep track of them and the GetUserName API function just gets it from that list. -- Reply to the group so all can participate VB.Net: "Fool me once..." Hi Bob:
fwiw, I notice that an Environment variable gets set when you login,i.e. USERNAME=myname Perhaps it just reads that. Doug. Show quoteHide quote "Bob Butler" <tiredofit@nospam.com> wrote in message news:eL5Af6uYFHA.4036@tk2msftngp13.phx.gbl... > "Cam" <n*@no.com> wrote in message > news:%23RQEx0uYFHA.2160@TK2MSFTNGP10.phx.gbl > > I am using the GetUserName API and want to know where the API looks to > > retrieve the username.I know the documentation say "The GetUserName > > function retrieves the user name of the current thread. This is the > > name of the user currently logged onto the system." > > Ok so where does it look. Is it in the registry? if so what hive. > > Any help would be great. > > My assumption would be that it is just in memory somewhere. The OS has a > list of active threads with all associated information that it needs to keep > track of them and the GetUserName API function just gets it from that list. > > -- > Reply to the group so all can participate > VB.Net: "Fool me once..." > "Douglas Marquardt" <no_spam@dummy.com> wrote in message IIRC, you can change the variable value and the API still returns thenews:%23T7MBcvYFHA.1412@TK2MSFTNGP12.phx.gbl > Hi Bob: > > fwiw, I notice that an Environment variable gets set when you > login,i.e. > > USERNAME=myname > > Perhaps it just reads that. correct name; that's the main reason why the variable is not reliable. -- Reply to the group so all can participate VB.Net: "Fool me once..." "Douglas Marquardt" <no_spam@dummy.com> wrote in message just to confirm that it doesn't:news:%23T7MBcvYFHA.1412@TK2MSFTNGP12.phx.gbl > Hi Bob: > > fwiw, I notice that an Environment variable gets set when you > login,i.e. > > USERNAME=myname > > Perhaps it just reads that. Private Declare Function GetUserName Lib "advapi32.dll" _ Alias "GetUserNameA" (ByVal lpBuffer As String, _ ByRef nSize As Long) As Long Private Declare Function GetEnvironmentVariable Lib "kernel32" _ Alias "GetEnvironmentVariableA" (ByVal lpName As String, _ ByVal lpBuffer As String, ByVal nSize As Long) As Long Private Declare Function SetEnvironmentVariable Lib "kernel32" _ Alias "SetEnvironmentVariableA" (ByVal lpName As String, _ ByVal lpValue As String) As Long Private Sub Main() Dim sName As String Dim x As Long Dim n As Long x = SetEnvironmentVariable("USERNAME", "test") sName = Space$(32) x = GetEnvironmentVariable("USERNAME", sName, Len(sName)) Debug.Print "GEV=" & sName sName = Space$(32) n = Len(sName) x = GetUserName(sName, n) Debug.Print "GUN=" & sName End Sub I get: GEV=test GUN=bob -- Reply to the group so all can participate VB.Net: "Fool me once..." Hi Bob:
No need to confirm.... I believed ha ;-) Doug. Show quoteHide quote "Bob Butler" <tiredofit@nospam.com> wrote in message news:evgovywYFHA.3516@TK2MSFTNGP10.phx.gbl... > "Douglas Marquardt" <no_spam@dummy.com> wrote in message > news:%23T7MBcvYFHA.1412@TK2MSFTNGP12.phx.gbl > > Hi Bob: > > > > fwiw, I notice that an Environment variable gets set when you > > login,i.e. > > > > USERNAME=myname > > > > Perhaps it just reads that. > > just to confirm that it doesn't: > > Private Declare Function GetUserName Lib "advapi32.dll" _ > Alias "GetUserNameA" (ByVal lpBuffer As String, _ > ByRef nSize As Long) As Long > Private Declare Function GetEnvironmentVariable Lib "kernel32" _ > Alias "GetEnvironmentVariableA" (ByVal lpName As String, _ > ByVal lpBuffer As String, ByVal nSize As Long) As Long > Private Declare Function SetEnvironmentVariable Lib "kernel32" _ > Alias "SetEnvironmentVariableA" (ByVal lpName As String, _ > ByVal lpValue As String) As Long > > Private Sub Main() > Dim sName As String > Dim x As Long > Dim n As Long > x = SetEnvironmentVariable("USERNAME", "test") > sName = Space$(32) > x = GetEnvironmentVariable("USERNAME", sName, Len(sName)) > Debug.Print "GEV=" & sName > sName = Space$(32) > n = Len(sName) > x = GetUserName(sName, n) > Debug.Print "GUN=" & sName > End Sub > > I get: > GEV=test > GUN=bob > > > -- > Reply to the group so all can participate > VB.Net: "Fool me once..." > That should be 'ya', not 'ha'.
Show quoteHide quote "Douglas Marquardt" <no_spam@dummy.com> wrote in message news:emwzdK%23YFHA.2664@TK2MSFTNGP15.phx.gbl... > Hi Bob: > > No need to confirm.... I believed ha ;-) > > Doug. > > "Bob Butler" <tiredofit@nospam.com> wrote in message news:evgovywYFHA.3516@TK2MSFTNGP10.phx.gbl... > > "Douglas Marquardt" <no_spam@dummy.com> wrote in message > > news:%23T7MBcvYFHA.1412@TK2MSFTNGP12.phx.gbl > > > Hi Bob: > > > > > > fwiw, I notice that an Environment variable gets set when you > > > login,i.e. > > > > > > USERNAME=myname > > > > > > Perhaps it just reads that. > > > > just to confirm that it doesn't: > > > > Private Declare Function GetUserName Lib "advapi32.dll" _ > > Alias "GetUserNameA" (ByVal lpBuffer As String, _ > > ByRef nSize As Long) As Long > > Private Declare Function GetEnvironmentVariable Lib "kernel32" _ > > Alias "GetEnvironmentVariableA" (ByVal lpName As String, _ > > ByVal lpBuffer As String, ByVal nSize As Long) As Long > > Private Declare Function SetEnvironmentVariable Lib "kernel32" _ > > Alias "SetEnvironmentVariableA" (ByVal lpName As String, _ > > ByVal lpValue As String) As Long > > > > Private Sub Main() > > Dim sName As String > > Dim x As Long > > Dim n As Long > > x = SetEnvironmentVariable("USERNAME", "test") > > sName = Space$(32) > > x = GetEnvironmentVariable("USERNAME", sName, Len(sName)) > > Debug.Print "GEV=" & sName > > sName = Space$(32) > > n = Len(sName) > > x = GetUserName(sName, n) > > Debug.Print "GUN=" & sName > > End Sub > > > > I get: > > GEV=test > > GUN=bob > > > > > > -- > > Reply to the group so all can participate > > VB.Net: "Fool me once..." > > > >
Accelerating Extraction of Bits From Text
Form Failed to load control...Your version of ocx may be outdated.. Folder loading problem. Support Classic VB VB 6 and MS-Word question Quotation mark as string how to pass over events in stacked objects? Package/Deployment Wizard Can I develop VB6 App for windows CE? |
|||||||||||||||||||||||