葬
葬月
Unregistered / Unconfirmed
GUEST, unregistred user!
比如说服务端有个
STDMETHODIMP TTextServerImpl::Test(VARIANT s)
{
TVariant f;
f=s;
void * ptr;
int DataSize= VarArrayHighBound(f,1) - VarArrayLowBound(f,1);
ptr = VarArrayLock(f);
TMemoryStream * aStr;
aStr = new TMemoryStream;
aStr->Write(ptr,DataSize);
VarArrayUnlock(f);
aStr->Seek(0,0);
aStr->SaveToFile("e://ss.exe");
delete aStr;
}
在客户端
TMemoryStream *m=new TMemoryStream();
m->LoadFromFile("d://ime.exe");
int iSize = m->Size;
int Bounds[] = {0,iSize-1};
Variant vtData = VarArrayCreate(Bounds,1,varByte);
void * pDatas = VarArrayLock(vtData);
m->Position =0;
m->Read(pDatas,iSize);
VarArrayUnlock(vtData);
MainForm->m_DCOMConnection->AppServer.OleFunction("Test",vtData);
但是却说服务端发生意外事故
我哪里错了?应该怎么做?
STDMETHODIMP TTextServerImpl::Test(VARIANT s)
{
TVariant f;
f=s;
void * ptr;
int DataSize= VarArrayHighBound(f,1) - VarArrayLowBound(f,1);
ptr = VarArrayLock(f);
TMemoryStream * aStr;
aStr = new TMemoryStream;
aStr->Write(ptr,DataSize);
VarArrayUnlock(f);
aStr->Seek(0,0);
aStr->SaveToFile("e://ss.exe");
delete aStr;
}
在客户端
TMemoryStream *m=new TMemoryStream();
m->LoadFromFile("d://ime.exe");
int iSize = m->Size;
int Bounds[] = {0,iSize-1};
Variant vtData = VarArrayCreate(Bounds,1,varByte);
void * pDatas = VarArrayLock(vtData);
m->Position =0;
m->Read(pDatas,iSize);
VarArrayUnlock(vtData);
MainForm->m_DCOMConnection->AppServer.OleFunction("Test",vtData);
但是却说服务端发生意外事故
我哪里错了?应该怎么做?