Date: 02-16-2022
Return to Index
created by gbSnippets
'Network analysts find the need to know which computers are on the
'local network. The GetComputerName function does the trick, as does
'the PowerBASIC Host Name function.
'Primary Code:
Dim CName As Asciiz * %Max_Path, HostName$
GetComputerName CName,SizeOf(CName) 'computer name is in CName
Host Name To HostName$
'the computer name is found in the registry at:
'HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName
'Compilable Example: (Jose Includes)
'uses PowerBASIC function HOST NAME
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
Dim HostName$
Host Name TO HostName$
MsgBox HostName$
End If
End Function
'gbs_00246
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm