本文整理汇总了C++中CString::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::GetData方法的具体用法?C++ CString::GetData怎么用?C++ CString::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::GetData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CString AFXAPI operator+(const CString& string1, const CString& string2)
{
CString s;
s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData,
string2.GetData()->nDataLength, string2.m_pchData);
return s;
}
示例2: AfxIsValidString
CString AFXAPI operator+(LPCTSTR lpsz, const CString& string)
{
ASSERT(lpsz == NULL || AfxIsValidString(lpsz, FALSE));
CString s;
s.ConcatCopy(CString::SafeStrlen(lpsz), lpsz, string.GetData()->nDataLength,
string.m_pchData);
return s;
}
示例3: GetStringFromFile
void CLocalizationEngine::GetStringFromFile(CString* aFileName, CString* aCategoryName, CString* aStringName, CString* aToHoldLocalizedString)
{
for(TInt lFileIndex = 0; lFileIndex < iFileEntries->GetCount(); lFileIndex++)
{
if(iFileEntries->Get(lFileIndex)->FileName->EqualTo(aFileName))
{
CPointerArray<SCategoryEntry>* lCategory = iFileEntries->Get(lFileIndex)->iCategoryEntries;
for(TInt lCategoryIndex = 0; lCategoryIndex < lCategory->GetCount(); lCategoryIndex++)
{
if(lCategory->Get(lCategoryIndex)->CategoryName->EqualTo(aCategoryName))
{
//found the correct category
CPointerArray<SStringEntry>* lStringEntries = lCategory->Get(lCategoryIndex)->StringEntries;
for(TInt lStringIndex = 0; lStringIndex < lStringEntries->GetCount(); lStringIndex++)
{
if(lStringEntries->Get(lStringIndex)->StringId->EqualTo(aStringName))
{
//need to convert the Filename to work on platform and with the correct language
CString* lCompleteFileName = GetFullPathForFileName(aFileName->GetData());
//found the String that we need
TUint lLengthInBytes = lStringEntries->Get(lStringIndex)->LengthOfStringInBytes;
TUint lOffSetInBytes = lStringEntries->Get(lStringIndex)->ByteOffset;
TUint8* lRawData = CAssetDirectory::ReadBytesFromAssetFile(lCompleteFileName->GetData(), lLengthInBytes, lOffSetInBytes);
TUint8* lStringData = new TUint8[lLengthInBytes + 1]; //plus 1 for NULL terminating character
//need to append the NULL terminating character to this String
memcpy(lStringData, lRawData, lLengthInBytes);
lStringData [lLengthInBytes] = '\0';
//create the final String
aToHoldLocalizedString->Replace((char*) lStringData);
delete[] lRawData;
delete[] lStringData;
delete lCompleteFileName;
return; //found what we wanted
}
}
}
}
}
}
}
示例4:
CString AFXAPI operator+(const CString& string1, TCHAR ch)
{
CString s;
s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData, 1, &ch);
return s;
}
示例5: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
// Get the GTA IV install directory from the registry
char szInstallDirectory[MAX_PATH];
bool bFoundCustomDirectory = false, bRenewProtocol = false;
std::string strReNewEntries = lpCmdLine;
if(SharedUtility::ReadRegistryString(HKEY_CURRENT_USER, "Software\\IVMP", "gtaivdir", NULL,
szInstallDirectory, sizeof(szInstallDirectory)) ||
!SharedUtility::Exists(szInstallDirectory))
{
char szProtocolDirectory[MAX_PATH];
CString strCommand = CString("\"%s\" \"%%1\"",SharedUtility::GetAbsolutePath("Client.Launcher.exe"));
if(strcmp(szProtocolDirectory, strCommand.Get()))
bRenewProtocol = true;
}
// Check if protocol 'ivmp' and 'ivmultiplayer' is avaiable in registry
if(!SharedUtility::ReadRegistryString(HKEY_CLASSES_ROOT, "ivmp", NULL, "", NULL, NULL)
|| !SharedUtility::ReadRegistryString(HKEY_CLASSES_ROOT, "ivmultiplayer", NULL, "", NULL, NULL)
|| bRenewProtocol)
{
// Update
SharedUtility::WriteRegistryString(HKEY_CLASSES_ROOT,"ivmp","","IVMultiplayer",strlen("IVMultiplayer"));
SharedUtility::WriteRegistryString(HKEY_CLASSES_ROOT,"ivmultiplayer","","IVMultiplayer",strlen("IVMultiplayer"));
CString strcommand = CString("\"%s\" \"%%1\"",SharedUtility::GetAbsolutePath("Client.Launcher.exe"));
SharedUtility::WriteRegistryString(HKEY_CLASSES_ROOT,"ivmp","Url Protocol","",0);
SharedUtility::WriteRegistryString(HKEY_CLASSES_ROOT,"ivmp\\shell\\open\\command\\","",strcommand.GetData(),strcommand.GetLength());
SharedUtility::WriteRegistryString(HKEY_CLASSES_ROOT,"ivmp\\DefaultIcon","", CString("Client.Launcher.exe,1").GetData(),strlen("Client.Launcher.exe,1"));
SharedUtility::WriteRegistryString(HKEY_CLASSES_ROOT,"ivmultiplayer","Url Protocol","",0);
SharedUtility::WriteRegistryString(HKEY_CLASSES_ROOT,"ivmultiplayer\\shell\\open\\command\\","",strcommand.GetData(),strcommand.GetLength());
SharedUtility::WriteRegistryString(HKEY_CLASSES_ROOT,"ivmultiplayer\\DefaultIcon","", CString("Client.Launcher.exe,1").GetData(),strlen("Client.Launcher.exe,1"));
}
// TODO: Steam registry entry support(or the client should just pick the directory via data browser)
if(!SharedUtility::ReadRegistryString(HKEY_LOCAL_MACHINE, "Software\\Rockstar Games\\Grand Theft Auto IV",
"InstallFolder", NULL, szInstallDirectory, sizeof(szInstallDirectory)) ||
!SharedUtility::Exists(szInstallDirectory)) {
if(!SharedUtility::ReadRegistryString(HKEY_CURRENT_USER, "Software\\IVMP", "gtaivdir", NULL,
szInstallDirectory, sizeof(szInstallDirectory)) ||
!SharedUtility::Exists(szInstallDirectory)) {
if(ShowMessageBox("Failed to retrieve GTA IV install directory from registry. Specify your GTA IV path now?",
(MB_ICONEXCLAMATION | MB_OKCANCEL)) == IDOK) {
// Taken from http://vcfaq.mvps.org/sdk/20.htm
BROWSEINFO browseInfo = { 0 };
browseInfo.lpszTitle = "Pick a Directory";
ITEMIDLIST * pItemIdList = SHBrowseForFolder(&browseInfo);
if(pItemIdList != NULL) {
// Get the name of the selected folder
if(SHGetPathFromIDList(pItemIdList, szInstallDirectory))
bFoundCustomDirectory = true;
// Free any memory used
IMalloc * pIMalloc = 0;
if(SUCCEEDED(SHGetMalloc(&pIMalloc))) {
pIMalloc->Free(pItemIdList);
pIMalloc->Release();
}
}
}
if(!bFoundCustomDirectory) {
ShowMessageBox("Failed to retrieve GTA IV install directory from registry or browser window. Cannot launch IV: Multiplayer.");
return 1;
}
}
}
// Check if we have the 'multiplayer' directory, if not: create it.
char szExecutablePath[MAX_PATH];
sprintf_s(szExecutablePath,SharedUtility::GetAbsolutePath("").Get(),sizeof(MAX_PATH));
CString strMultiplayerPath = szExecutablePath;
strMultiplayerPath.AppendF ("multiplayer");
SharedUtility::CreateDirectoryA(strMultiplayerPath.Get());
strMultiplayerPath = szExecutablePath;
strMultiplayerPath.AppendF ("multiplayer\\common");
SharedUtility::CreateDirectoryA(strMultiplayerPath.Get());
SharedUtility::CreateDirectoryA(strMultiplayerPath.Get());
strMultiplayerPath = szExecutablePath;
strMultiplayerPath.AppendF ("multiplayer\\pc");
SharedUtility::CreateDirectoryA(strMultiplayerPath.Get());
SharedUtility::CreateDirectoryA(strMultiplayerPath.Get());
strMultiplayerPath = szExecutablePath;
strMultiplayerPath.AppendF ("multiplayer\\pc\\data");
SharedUtility::CreateDirectoryA(strMultiplayerPath.Get());
strMultiplayerPath = szExecutablePath;
strMultiplayerPath.AppendF ("multiplayer\\common\\data");
//.........这里部分代码省略.........
示例6: BuildIndexForLanguageFile
void CLocalizationEngine::BuildIndexForLanguageFile(CString* aFileName)
{
//find FileIndex and reset other attributes
iFileIndex = -1;
for(TInt lFileIndex = 0; lFileIndex < iFileEntries->GetCount(); lFileIndex++)
{
if(iFileEntries->Get(lFileIndex)->FileName->EqualTo(aFileName))
{
iFileIndex = lFileIndex;
break;
}
}
//reset state to be ready for reading data
iState = EStateReady;
iCategoryIndex = -1;
iStringIndex = -1;
iByteLocationInFile = 0;
CString* lFullPath = GetFullPathForFileName(aFileName->GetData());
TInt lFileContentSize = CAssetDirectory::GetAssetFileSizeInBytes(lFullPath->GetData());
TUint8* lFileContent = CAssetDirectory::ReadAssetFile(lFullPath->GetData());
//need to expend the memory block by 1 byte to append the NULL character
lFileContent = (TUint8*) realloc(lFileContent, sizeof(TUint8) * (lFileContentSize + 1));
lFileContent[lFileContentSize] = '\0';
//convert the file content to a CString
CString* lFileContentAsString = new CString((char*) lFileContent);
//clean up
delete[] lFileContent; //made a copy of it
delete lFullPath;
//go through the file and build up an index to the String Values
for (TInt lIndex = 0; lIndex < lFileContentAsString->GetLength(); lIndex++)
{
CString* lCharacter = lFileContentAsString->GetSubString(lIndex, 1);
switch (iState)
{
case EStateReady:
{
HandleReadyState(lCharacter);
break;
}
case EStateLookingForEndOfCategoryName:
{
HandleEndOfCategoryNameState(lCharacter);
break;
}
case EStateLookingForEndOfStringId:
{
HandleEndOfStringId(lCharacter);
break;
}
case EStateLookingForBeginningOfStringValue:
{
HandleBeginningOfStringValue(lCharacter);
break;
}
case EStateLookingForEndOfStringValue:
{
HandleEndOfStringValue(lCharacter);
break;
}
case EStateComment:
{
HandleCommentState(lCharacter);
break;
}
}
iByteLocationInFile += lCharacter->GetSizeOfStringInBytes(); //need increment the byte Location
delete lCharacter; //not needed anymore
}
//not needed anymore
delete lFileContentAsString;
}