|
-
August 31st, 2001, 04:18 AM
#1
GetComputerName() function
Why is my program doesn't recognize the function
GetComputerName()? Do I need to include some dll for these to run?
Please help.
Thanks.
cecile
The more u read, the more u do not know
-
August 31st, 2001, 04:25 AM
#2
Re: GetComputerName() function
GetComputerName is an API function
U must declare in declaration zone...
public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (byval lpBuffer as string, nSize as Long) as Long
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
</center>
-
August 31st, 2001, 04:30 AM
#3
Re: GetComputerName() function
The function is part of the API try this:
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (byval lpBuffer as string, nSize as Long) as Long
Note also that there are returned parameters, so you would eventually get the computername from left$(sBuffer,lSize).
HTH
-
August 31st, 2001, 06:56 AM
#4
Re: GetComputerName() function
'from api-guide (a free tool!)
'Requires Windows NT 3.1 or later; Requires Windows 95 or later
'The GetComputerName function retrieves the computer name of the current
'system.
'This name is established at system startup, when it is initialized from the
'registry
'copy paste this in a form code, or change the api declaration to public
'to use it from a .bas module
private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (byval lpBuffer as string, nSize as Long) as Long
private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim strString as string
'Create a buffer
strString = string(255, Chr$(0))
'get the computer name
GetComputerName strString, 255
'remove the unnecessary chr$(0)'s
strString = Left$(strString, InStr(1, strString, Chr$(0)) - 1)
'Show the computer name
MsgBox strString
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|