P
pascal
Unregistered / Unconfirmed
GUEST, unregistred user!
function GetSQLServerList(var AList: TStrings): Boolean ;
var
SQLServer : Variant;
ServerList: Variant;
i: Integer;
begin
Result := True;
try
SQLServer := CreateOleObject('SQLDMO.Application');
ServerList:= SQLServer.ListAvailableSQLServers;
if serverlist.count>0
then
for i:=1 to ServerList.Countdo
AList.Add(ServerList.Item(i))
else
Result := false ;
SQLServer := NULL ;
ServerList := NuLL ;
except
Result := False;
end;
end;
译文:
bool __fastcall GetSQLServerList(TStrings *AList)
{
Variant SQLServer;
Variant ServerList;
bool Result = true;
try
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// Coinitialize(NULL);
SQLServer = CreateOleObject("SQLDMO.Application"
ServerList= SQLServer->ListAvailableSQLServers;
//这里编译不过ointer to structure required on left side of -> or ->*
/*
这样也不行:
ServerList= SQLServer.ListAvailableSQLServers;
//ListAvailableSQLServers is not a member of 'Variant'
ServerList= (_di_IDispatch *)SQLServer->ListAvailableSQLServers;
//pointer to structure required on left side of -> or ->*
*/
if (0 < serverlist.count)
for (i=1;ServerList.Count;i++) AList.Add(ServerList.Item(i))
else
Result = false ;
SQLServer = NULL ;
ServerList = NULL ;
CoUninitialize();
}
catch (...)
{ Result = False;}
return Result;
}
var
SQLServer : Variant;
ServerList: Variant;
i: Integer;
begin
Result := True;
try
SQLServer := CreateOleObject('SQLDMO.Application');
ServerList:= SQLServer.ListAvailableSQLServers;
if serverlist.count>0
then
for i:=1 to ServerList.Countdo
AList.Add(ServerList.Item(i))
else
Result := false ;
SQLServer := NULL ;
ServerList := NuLL ;
except
Result := False;
end;
end;
译文:
bool __fastcall GetSQLServerList(TStrings *AList)
{
Variant SQLServer;
Variant ServerList;
bool Result = true;
try
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// Coinitialize(NULL);
SQLServer = CreateOleObject("SQLDMO.Application"
ServerList= SQLServer->ListAvailableSQLServers;
//这里编译不过ointer to structure required on left side of -> or ->*
/*
这样也不行:
ServerList= SQLServer.ListAvailableSQLServers;
//ListAvailableSQLServers is not a member of 'Variant'
ServerList= (_di_IDispatch *)SQLServer->ListAvailableSQLServers;
//pointer to structure required on left side of -> or ->*
*/
if (0 < serverlist.count)
for (i=1;ServerList.Count;i++) AList.Add(ServerList.Item(i))
else
Result = false ;
SQLServer = NULL ;
ServerList = NULL ;
CoUninitialize();
}
catch (...)
{ Result = False;}
return Result;
}