关于GetComputerForProgID(const void *ProgID);
按照书中Delphi的实例编写的容错处理,但是编译通不过,请问如何处理?
源码如下:
try {
MIDAS-> Connected=true;
}catch(...)
{
MIDAS-> Connected=false;
SimpleObjectBroker1-> SetConnectStatus(MIDAS-> Host,false);
try{
AnsiString sMachine=SimpleObjectBroker1-> GetComputerForProgID(MIDAS-> ServerName);
MIDAS-> ServerGUID=sMachine;
MIDAS-> Connected=true;
}
catch(...)
{ ShowMessage( "无法连接服务器 ");
}
}
错误信息为:
[C++ Error] MainData.cpp(52): E2034 Cannot convert 'AnsiString ' to 'const void * '.
[C++ Error] MainData.cpp(52): E2343 Type mismatch in parameter 'ProgID ' in call to '_fastcall TSimpleObjectBroker::GetComputerForProgID(const void *) '
[解决办法]
试试:
SimpleObjectBroker1-> GetComputerForProgID(MIDAS-> ServerName.c_str());