我如何才能从程序中登录另一个服务器(200分)

N

nj_xxq

Unregistered / Unconfirmed
GUEST, unregistred user!
计算机A已加入域,但在使用中又要登录另一个服务器,在CB中中用Windows API 帮助查到函数NetWkstaGetInfo,但使用却报错;又查到函数NetworkConnect,但却找不到头文件
 
winexcute('telnet ...');
 
但是我说的是用API函数,而不是用外部命令,我用NetWkstaGetInfo需要什么头文件吗
 
IWPSiteW::NetworkConnect Method
HRESULT NetworkConnect(LPCWSTR wsUserName, LPCWSTR wsPassword);
IWPSiteW Interface
This interface provides the methods each Internet service provider must support to allow the core Web Publishing services to post content
Inherits from IUnknown
IDL files wpspi.idl
 
softBugg:对不起,我上网不是太方便,到今天才看到贴子
IWPSiteW是什么类,我怎么查不到?
代码:
 
用API WNetAddConnection2,给你一个例子:
function Tmydata.LoginOcrServer(UserName,PassWD:string):boolean;
var
hr:integer;
nr:TNetResource;
begin
result := true;
fillchar(nr,sizeof(nr),#0);
nr.lpRemoteName:='//ocrserver/hwdata';
nr.dwScope:=RESOURCETYPE_ANY;
hr:=WNetAddConnection2(nr,pchar(PassWD),pchar(UserName),0);
if (hr>0) and (hr <> ERROR_ALREADY_ASSIGNED) and (hr <> ERROR_SESSION_CREDENTIAL_CONFLICT) then
result := false;
end;
 
多人接受答案了。
 
顶部