在下面的函数中,每次执行到isp.GetDirectCallerSID(SID);时,系统总是报“灾难性错误”
function TCoolObject.GetDirectCaller: String;
var
isp : ISecurityProperty;
SID : PSID;
bResult : Boolean;
sName : array[0..255] of char;
sDomainName : array[0..255] of char;
NameUse : SID_NAME_USE;
NameLength : DWORD;
DomainLength : DWORD;
begin
try
isp := ObjectContext as ISecurityProperty;
/////////////////////////////////
/////////////////////////////////
isp.GetDirectCallerSID(SID);
NameLength := 255;
DomainLength := 255;
bResult := LookupAccountSid(nil, SID, sName, NameLength,sDomainName, DomainLength, NameUse);
if (bREsult) then
Result := sName;
finally
isp.ReleaseSID(SID);
end;
end;
function TCoolObject.GetDirectCaller: String;
var
isp : ISecurityProperty;
SID : PSID;
bResult : Boolean;
sName : array[0..255] of char;
sDomainName : array[0..255] of char;
NameUse : SID_NAME_USE;
NameLength : DWORD;
DomainLength : DWORD;
begin
try
isp := ObjectContext as ISecurityProperty;
/////////////////////////////////
/////////////////////////////////
isp.GetDirectCallerSID(SID);
NameLength := 255;
DomainLength := 255;
bResult := LookupAccountSid(nil, SID, sName, NameLength,sDomainName, DomainLength, NameUse);
if (bREsult) then
Result := sName;
finally
isp.ReleaseSID(SID);
end;
end;
CreateOleObject、CoInitializeEx 怎么加入??
CoInitialize(nil);
try
isp := ObjectContext as ISecurityProperty;
/////////////////////////////////
/////////////////////////////////
isp.GetDirectCallerSID(SID);
NameLength := 255;
DomainLength := 255;
bResult := LookupAccountSid(nil, SID, sName, NameLength,sDomainName, DomainLength, NameUse);
if (bREsult) then
Result := sName;
finally
CoUninitialize;
end;
CoInitialize(nil)在服务端,还是在客户端调用?
还有没有别的办法解决?