Z zhl123 Unregistered / Unconfirmed GUEST, unregistred user! 2003-03-12 #1 我用了api函數gethostname,但是不知道怎麼調用它,老出錯,請各位幫一下忙,是不是<br>需加入什麼單元,還有裡面的參數怎樣調用
雪 雪中漫步 Unregistered / Unconfirmed GUEST, unregistred user! 2003-03-12 #2 var<br> scname:array[1..MAX_COMPUTERNAME_LENGTH] of char;<br> nSize: DWORD;<br>begin<br> result:='';<br> nSize:=MAX_COMPUTERNAME_LENGTH+1;<br> if GetComputerName(@scname,nSize) then<br> begin<br> result:=lowercase(trim(scname));<br> end;<br>end;<br>
var<br> scname:array[1..MAX_COMPUTERNAME_LENGTH] of char;<br> nSize: DWORD;<br>begin<br> result:='';<br> nSize:=MAX_COMPUTERNAME_LENGTH+1;<br> if GetComputerName(@scname,nSize) then<br> begin<br> result:=lowercase(trim(scname));<br> end;<br>end;<br>
P pink_wt Unregistered / Unconfirmed GUEST, unregistred user! 2003-03-12 #4 uses shellapi;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> pchar;<br> size:dword;<br>begin<br>size:=255;<br> getmem(p,size);<br> GetComputerName(p,size);<br> edit1.Text:=string(p);<br> freemem(p);<br>end;
uses shellapi;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> pchar;<br> size:dword;<br>begin<br>size:=255;<br> getmem(p,size);<br> GetComputerName(p,size);<br> edit1.Text:=string(p);<br> freemem(p);<br>end;