很短的一段VC代码转D代码
char strBuf[1024] = {0};
CFile file;
char* pReadbuf = NULL;
char* pSend = NULL;
long lSize = 0;
if(!file.Open("e:\\x1.jpg", CFile::modeRead | CFile::shareDenyWrite))
{
//_OutPut("打开文件失败\n");
}
else
{
lSize = file.GetLength();
pReadbuf = new char[lSize];
memset(pReadbuf, 0, lSize);
CString strCMD;
strCMD.Format("<ILAS>31;;T00516;%d;", lSize);
int nCmdLen = strlen(strCMD);
file.ReadHuge(pReadbuf, lSize);
//ADD ;</ILAS>
int nSendSize = nCmdLen + lSize + 8;
pSend = new char[nSendSize];
memset(pSend, 0, nSendSize);
memcpy(pSend, strCMD.GetBuffer(0), nCmdLen);
memcpy(pSend + nCmdLen, pReadbuf, lSize);
char strTmp[] = ";</ILAS>";
memcpy(pSend + nCmdLen + lSize, strTmp, strlen(strTmp));
delete[] pReadbuf;
delete[] pSend;
}