- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use the GetComputerName / GetUserName functions but I get an error when I run them - the parameters must be wrong.
Does anyone have a example of using these functions, or is there a better way to get the Computer Name / User Name?
Thanks, David
Does anyone have a example of using these functions, or is there a better way to get the Computer Name / User Name?
Thanks, David
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's fishy declaration of GetComputerName / GetUserName in ADVAPI32.f90 and KERNEL32.f90. The docs say that nSize argument is actually, speaking in fortran terms, INTENT(INOUT), i.e. it's a pointer to an integer, not integer-by-value. Thus, it would be more natural that the fortran declaration has !DEC$ATTRIBUTES REFERENCE:: nSize
Workaround for that is to pass LOC(nSize) argument, not nSize:
Jugoslav
Workaround for that is to pass LOC(nSize) argument, not nSize:
CHARACTER(40):: sUser nSize=40 bSt=GetUserName(sUser,LOC(nSize))
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INTEGER*4 Result
CHARACTER*(As long as needed) UserName, CompName
Result = GETENVQQ("USERNAME", UserName)
Result = GETENVQQ("COMPUTERNAME", CompName)
USERNAME and COMPUTERNAME are true for W2K. Enter SET at command line to see what they are called in your OS.
Sabalan.
CHARACTER*(As long as needed) UserName, CompName
Result = GETENVQQ("USERNAME", UserName)
Result = GETENVQQ("COMPUTERNAME", CompName)
USERNAME and COMPUTERNAME are true for W2K. Enter SET at command line to see what they are called in your OS.
Sabalan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
USE DFLIB
INTEGER*4 Result
CHARACTER*(As long as needed) UserName, CompName
Result = GETENVQQ("USERNAME", UserName)
Result = GETENVQQ("COMPUTERNAME", CompName)
USERNAME and COMPUTERNAME are true for W2K. Enter SET at command line to see what they are called in your OS.
Sabalan.
INTEGER*4 Result
CHARACTER*(As long as needed) UserName, CompName
Result = GETENVQQ("USERNAME", UserName)
Result = GETENVQQ("COMPUTERNAME", CompName)
USERNAME and COMPUTERNAME are true for W2K. Enter SET at command line to see what they are called in your OS.
Sabalan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, they both worked fine.
David
David

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page