110,536
社区成员
发帖
与我相关
我的任务
分享
[DllImport("Assist.dll", EntryPoint = "SetXMLTextInEncryptFileConfig", CallingConvention = CallingConvention.Cdecl)]
public static extern void SetXMLTextInEncryptFileConfig(string strEncryptFilePath, String pszDomain, String pszKey, Int32 pos, [MarshalAs(UnmanagedType.LPWStr)]String tag, [MarshalAs(UnmanagedType.LPWStr)]String content);
public void SetXMLTextInConfigInfo(string pszDomain, string pszKey, int pos, string tag, string content)
{
SetXMLTextInEncryptFileConfig(Path_ConfigInfo, pszDomain, pszKey, pos, tag, content);
}
void SetXMLTextInEncryptFileConfig(char* strEncryptFilePath,char* pszDomain, char* pszKey, size_t pos, wchar_t *tag, wchar_t *content)
{
CString EncryptFilePath = strEncryptFilePath;
CString strDomain = pszDomain;
CString strKey = pszKey;
CSimpleRefCnt<CEncryptFiles> pSPEncryptFile = qqmusic::GetEncryptFile(EncryptFilePath);
wchar_t *pWValue;
if(pSPEncryptFile.IsValid())
{
if(!pSPEncryptFile->GetValueAsString(strDomain,strKey,&pWValue))
{
return;
}
int nWValueLen = wcslen(pWValue);
wchar_t *pCValue = new wchar_t[nWValueLen*2];
ZeroMemory(pCValue, nWValueLen*2);
wchar_t *pHead = new wchar_t[pos];
ZeroMemory(pHead, pos);
printf("pWValue is %ls", pWValue);
wcsncpy(pHead, pWValue, pos);
printf("pHead is %ls", pHead);
wchar_t *pTail;
pTail = wcsstr(pWValue, tag);
wcsncat(pCValue,pHead, pos);
wcscat(pCValue,L"\n");
wcscat(pCValue,content);
wcscat(pCValue,L"\r\n");
int n = wcslen(content);
wcscat(pCValue,pTail);
wcscat(pCValue,L"\0");
string configString = pSPEncryptFile->SetValue(strDomain,strKey,pCValue);
CEncryptFile* pEncryptFile = new CEncryptFile();
pEncryptFile->SaveDat(strEncryptFilePath,configString);
delete[] pHead;
delete[] pCValue;
delete pEncryptFile;
}
}
wcsncat(pCValue,pHead, pos);
这一行时,就挂掉了。