谁知道Windows中Net Send使用的是那个API(50分)

  • 主题发起人 主题发起人 wyb_star
  • 开始时间 开始时间
W

wyb_star

Unregistered / Unconfirmed
GUEST, unregistred user!
谁知道Windows中Net Send使用的是那个API,我想在我的程序中调用Net Send使用的API,
我本来以为它没有API的,但我发现微软的软件中有调用Net Send功能的。谁知道它的API
是什么?
 
unit NetSend;
interfaceuses
Windows;
const
netapi = 'netapi32.dll';
type
LPBYTE = PByte;
NET_API_STATUS = DWord;
const
// success
NERR_Success = 0;
// Base address of error codes
NERR_BASE = 2100;
// A general network error occurred.
NERR_NetworkError = NERR_BASE + 36;
// The user name could not be found.
NERR_NameNotFound = NERR_BASE + 173;
// The user does not have access to the requested information.
// ERROR_ACCESS_DENIED - declared in Windows.pas (= 5)
// This network request is not supported.
// ERROR_NOT_SUPPORTED - declared in Windows.pas (=50)
// The specified parameter is invalid.
// ERROR_INVALID_PARAMETER - declared in Windows.pas (=87)
function NetMessageBufferSend(servername, msgname, fromname: LPCWSTR;
buf: LPBYTE; buflen: DWORD
): NET_API_STATUS; stdcall;
function NetSendMsg(serv, name, text: string): NET_API_STATUS;
implementation
function NetMessageBufferSend; external netapi name 'NetMessageBufferSend';
// serv = name of the remote server on which the function is to execute
// (The string must begin with // or empty ('') for local computer
// (you need some privileges to do this on other machines ;)
// name = the message alias to which the message should be sent
// text = string that contains the message text (multiline is no problem)
function NetSendMsg(serv, name, text: string): NET_API_STATUS;
var
msgserv: PWideChar;
servlen: Cardinal;
msgname: PWideChar;
namelen: Cardinal;
msgtext: PWideChar;
textlen: Cardinal;
begin
Result := ERROR_INVALID_PARAMETER;
servlen := 2 * (Length(serv) + 1);
namelen := 2 * (Length(name) + 1);
textlen := 2 * (Length(text) + 1);
if (servlen > 2) then msgserv := GetMemory(servlen) else msgserv := nil;
msgname := GetMemory(namelen);
msgtext := GetMemory(textlen);
if Assigned(msgname) and Assigned(msgtext) then
try
if Assigned(msgserv) then StringToWideChar(serv, msgserv, servlen div 2);
StringToWideChar(name, msgname, namelen div 2);
StringToWideChar(text, msgtext, textlen div 2);
Result := NetMessageBufferSend(msgserv, msgname, nil, PByte(msgtext), textlen);
finally
if Assigned(msgtext) then FreeMemory(msgtext);
if Assigned(msgname) then FreeMemory(msgname);
if Assigned(msgserv) then FreeMemory(msgserv);
end;
end;
end.
 
接受答案了.
 
后退
顶部