本文整理汇总了C++中StringCchCat函数的典型用法代码示例。如果您正苦于以下问题:C++ StringCchCat函数的具体用法?C++ StringCchCat怎么用?C++ StringCchCat使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringCchCat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cm_CloseCellFile
long cm_CloseCellFile(cm_configFile_t *filep)
{
char wdir[MAX_PATH];
char sdir[MAX_PATH];
long code;
long closeCode = fclose((FILE *)filep);
cm_GetConfigDir(wdir, sizeof(wdir));
if (FAILED(StringCchCopy(sdir, sizeof(sdir), wdir)))
return -1;
if (closeCode != 0) {
/* something went wrong, preserve original database */
if (FAILED(StringCchCat(wdir, sizeof(wdir), AFS_CELLSERVDB ".new")))
return -1;
unlink(wdir);
return closeCode;
}
if (FAILED(StringCchCat(wdir, sizeof(wdir), AFS_CELLSERVDB)))
return -1;
if (FAILED(StringCchCat(sdir, sizeof(sdir), AFS_CELLSERVDB ".new"))) /* new file */
return -1;
unlink(sdir); /* delete old file */
code = rename(sdir, wdir); /* do the rename */
if (code)
code = errno;
return code;
}
示例2: ZeroMemory
BOOL MyMacAddress::GetPNPDeviceID( const TCHAR *PNPDeviceID)
{
// GUID_NDIS_LAN_CLASS ad498944-762f-11d0-8dcb-00c04fc3358c
TCHAR DevicePath[MAX_PATH];
HANDLE hDeviceFile;
BOOL isOK = FALSE; // 生成设备路径名
ZeroMemory(DevicePath, sizeof(DevicePath));
StringCchCopy( DevicePath, MAX_PATH, TEXT("\\\\.\\"));
StringCchCat( DevicePath, MAX_PATH, PNPDeviceID );
StringCchCat( DevicePath, MAX_PATH, TEXT("#{ad498944-762f-11d0-8dcb-00c04fc3358c}") );
std::replace( DevicePath + 4, DevicePath + 4 + _tcslen(PNPDeviceID), TEXT('\\'), TEXT('#') ); // 获取设备句柄
hDeviceFile = CreateFile( DevicePath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if( hDeviceFile != INVALID_HANDLE_VALUE ){
ULONG dwID;
BYTE ucData[8];
DWORD dwByteRet;
dwID = OID_802_3_CURRENT_ADDRESS;
isOK = DeviceIoControl( hDeviceFile, IOCTL_NDIS_QUERY_GLOBAL_STATS, &dwID, sizeof(dwID), ucData, sizeof(ucData), &dwByteRet, NULL );
if( isOK )
{
memcpy(MACAddress, ucData, dwByteRet);
}
dwID = OID_802_3_PERMANENT_ADDRESS;
isOK = DeviceIoControl( hDeviceFile, IOCTL_NDIS_QUERY_GLOBAL_STATS, &dwID, sizeof(dwID), ucData, sizeof(ucData), &dwByteRet, NULL );
if( isOK )
{
memcpy(PermanentAddress, ucData, dwByteRet);
}
CloseHandle( hDeviceFile );
}
return isOK;
}
示例3: collect_cell_names
static khm_int32 KHMAPI
collect_cell_names(khm_handle cred, void * rock)
{
wchar_t *str = (wchar_t *) rock;
wchar_t cell[KCDB_MAXCCH_NAME] = L"";
FILETIME ft_now;
FILETIME ft_expire;
khm_size cb;
cb = sizeof(ft_expire);
if (KHM_FAILED(kcdb_cred_get_attr(cred, KCDB_ATTR_EXPIRE, NULL, &ft_expire, &cb)))
return KHM_ERROR_SUCCESS;
GetSystemTimeAsFileTime(&ft_now);
if (CompareFileTime(&ft_now, &ft_expire) >= 0)
return KHM_ERROR_SUCCESS;
cb = sizeof(cell);
if (KHM_SUCCEEDED(kcdb_cred_get_attr(cred, afs_attr_cell, NULL, cell, &cb)) &&
cell[0]) {
StringCchCat(str, COLLECT_STR_LEN, cell);
StringCchCat(str, COLLECT_STR_LEN, L"\n");
}
return KHM_ERROR_SUCCESS;
}
示例4: OnGetFileAttributes
static int OnGetFileAttributes(HWND hDlg)
{
TFileTestData * pData = GetDialogData(hDlg);
TFlagInfo * pFlags = FileAttributesValues;
TCHAR szFileAttributes[512] = _T("");
DWORD dwAttr;
int nError = ERROR_SUCCESS;
SaveDialog(hDlg);
dwAttr = GetFileAttributes(pData->szFileName1);
if(dwAttr != INVALID_FILE_ATTRIBUTES)
{
for(int i = 0; pFlags->dwValue != 0; i++, pFlags++)
{
if(IS_FLAG_SET(pFlags, dwAttr))
{
if(szFileAttributes[0] != 0)
StringCchCat(szFileAttributes, _countof(szFileAttributes), _T("\n"));
StringCchCat(szFileAttributes, _countof(szFileAttributes), pFlags->szFlagText);
}
}
if(szFileAttributes[0] == 0)
StringCchCopy(szFileAttributes, _countof(szFileAttributes), _T("0"));
MessageBoxRc(hDlg, IDS_FILE_ATTRIBUTES, (UINT_PTR)szFileAttributes);
}
else
nError = GetLastError();
SetResultInfo(hDlg, nError);
return TRUE;
}
示例5: GetCrashDescription
/**
* Get one line of text to describe the crash
*/
static void GetCrashDescription( WER_REPORT_INFORMATION& ReportInformation, const TCHAR* ErrorMessage )
{
if( ErrorMessage != NULL )
{
StringCchCat( ReportInformation.wzDescription, ARRAYSIZE( ReportInformation.wzDescription ), ErrorMessage );
}
else
{
StringCchCopy( ReportInformation.wzDescription, ARRAYSIZE( ReportInformation.wzDescription ), TEXT( "The application crashed while running " ) );
if( IsRunningCommandlet() )
{
StringCchCat( ReportInformation.wzDescription, ARRAYSIZE( ReportInformation.wzDescription ), TEXT( "a commandlet" ) );
}
else if( GIsEditor )
{
StringCchCat( ReportInformation.wzDescription, ARRAYSIZE( ReportInformation.wzDescription ), TEXT( "the editor" ) );
}
else if( GIsServer && !GIsClient )
{
StringCchCat( ReportInformation.wzDescription, ARRAYSIZE( ReportInformation.wzDescription ), TEXT( "a server" ) );
}
else
{
StringCchCat( ReportInformation.wzDescription, ARRAYSIZE( ReportInformation.wzDescription ), TEXT( "the game" ) );
}
}
}
示例6: GenerateFilename_OneFile
static BOOL GenerateFilename_OneFile(CONST HWND owner, CONST TCHAR *szDefault, UINT uiMode, TCHAR szFileOut[MAX_PATH_EX], BOOL askForFilename)
{
TCHAR szCurrentPath[MAX_PATH_EX] = TEXT("");
OPENFILENAME ofn;
size_t strLen;
StringCchLength(szDefault, MAX_PATH_EX, &strLen);
if(strLen > 4) { // if < 4 no extended path - something went wrong
// get rid of \\?\(UNC)
if(strLen > 6 && !_tcsncmp(szDefault + 4, TEXT("UNC"), 3)) {
szCurrentPath[0] = TEXT('\\');
StringCchCopy(szCurrentPath + 1, MAX_PATH_EX, szDefault + 7);
strLen -= 6;
} else {
StringCchCopy(szCurrentPath, MAX_PATH_EX, szDefault + 4);
strLen -= 4;
}
StringCchCopy(szFileOut, MAX_PATH_EX, szCurrentPath);
szCurrentPath[strLen - 1] = TEXT('\0'); // get rid of last backslash for GetFilenameWithoutPathPointer
StringCchCat(szFileOut, MAX_PATH_EX, GetFilenameWithoutPathPointer(szCurrentPath));
if(szCurrentPath[strLen - 2] == TEXT(':'))
szFileOut[4] = TEXT('\0');
} else {
StringCchCopy(szCurrentPath, MAX_PATH_EX, TEXT("C:\\"));
StringCchCopy(szFileOut, MAX_PATH_EX, TEXT("C:\\default"));
}
TCHAR *hashExt = g_hash_ext[uiMode];
// manually add file extension, windows dialog does not do this if the name already
// ends in a known extension
StringCchCat(szFileOut, MAX_PATH_EX, TEXT("."));
StringCchCat(szFileOut, MAX_PATH_EX, hashExt);
if(askForFilename) {
TCHAR msgString[MAX_PATH_EX];
TCHAR filterString[MAX_PATH_EX];
StringCchPrintf(filterString,MAX_PATH_EX,TEXT(".%s files%c*.%s%cAll files%c*.*%c"),hashExt,TEXT('\0'),hashExt,TEXT('\0'),TEXT('\0'),TEXT('\0'));
StringCchPrintf(msgString,MAX_PATH_EX,TEXT("Please choose a filename for the .%s file"),hashExt);
ZeroMemory(& ofn, sizeof (OPENFILENAME));
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.hwndOwner = owner;
ofn.lpstrFilter = filterString;
ofn.lpstrFile = szFileOut;
ofn.nMaxFile = MAX_PATH_EX;
ofn.lpstrInitialDir = szCurrentPath;
ofn.lpstrTitle = msgString;
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_NOCHANGEDIR;
ofn.lpstrDefExt = hashExt;
if(! GetSaveFileName(& ofn) ){
return FALSE;
}
}
return TRUE;
}
示例7: GetNewestLog
HANDLE GetNewestLog(_In_ TCHAR const * directory, _Out_ LPFILETIME const creationTime)
{
creationTime->dwHighDateTime = 0;
creationTime->dwLowDateTime = 0;
TCHAR dirPath[MAX_PATH];
size_t pathLength;
if (FAILED(StringCchLength(directory, MAX_PATH, &pathLength)) || pathLength + 3 > MAX_PATH)
{
return INVALID_HANDLE_VALUE;
}
StringCchCopy(dirPath, MAX_PATH, directory);
StringCchCat(dirPath, MAX_PATH, TEXT("\\*"));
TCHAR newestLog[MAX_PATH];
newestLog[0] = '\0';
WIN32_FIND_DATA ffd;
size_t nameLength;
HANDLE searchHandle = FindFirstFile(dirPath, &ffd);
if (searchHandle == INVALID_HANDLE_VALUE)
{
Log("ERROR | GetNewestLog | Couldn't enumerate files in", dirPath);
LogLastError();
return nullptr;
}
do
{
if (SUCCEEDED(StringCchLength(ffd.cFileName, MAX_PATH, &nameLength)) &&
_tcscmp(ffd.cFileName + nameLength - 4, TEXT(".txt")) == 0 &&
CompareFileTime(&ffd.ftCreationTime, creationTime) == 1)
{
StringCchCopy(newestLog, MAX_PATH, ffd.cFileName);
*creationTime = ffd.ftCreationTime;
}
}
while (FindNextFile(searchHandle, &ffd) != 0);
FindClose(searchHandle);
TCHAR path[MAX_PATH];
if (FAILED(StringCchLength(newestLog, MAX_PATH, &nameLength)) || pathLength + nameLength > MAX_PATH)
{
return INVALID_HANDLE_VALUE;
}
StringCchCopy(path, MAX_PATH, directory);
StringCchCat(path, MAX_PATH, TEXT("\\"));
StringCchCat(path, MAX_PATH, newestLog);
Log("INFO | GetNewestLog | Found newest log file at", path);
return CreateFile(path,
GENERIC_READ, // we only need to read
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, // let LoL do whatever it pleases (Mundo!)
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr);
}
示例8: SetTime
//------------------------------------------------------------------------------
// Name: SetTime()
// Desc: Update the slider and duration label with new time value.
//------------------------------------------------------------------------------
void SetTime( QWORD cnsTimeElapsed, QWORD cnsFileDuration )
{
//
// Do not set new time if seeking is going on
//
if( g_IsSeeking )
{
return;
}
DWORD dwSeconds = 0;
TCHAR tszTime[20];
TCHAR tszTemp[10];
UINT nHours = 0;
UINT nMins = 0;
ZeroMemory( (void *)tszTime, sizeof( tszTime ) );
dwSeconds = ( DWORD )( cnsTimeElapsed / 10000000 );
nHours = dwSeconds / 60 / 60;
dwSeconds %= 3600;
nMins = dwSeconds / 60;
dwSeconds %= 60;
//
// Format the string
//
if( 0 != nHours )
{
(void)StringCchPrintf( tszTemp, ARRAYSIZE(tszTemp), _T( "%d:" ), nHours );
(void)StringCchCat( tszTime, ARRAYSIZE(tszTime), tszTemp );
}
(void)StringCchPrintf( tszTemp, ARRAYSIZE(tszTemp), _T( "%02d:%02d / " ), nMins, dwSeconds );
(void)StringCchCat( tszTime, ARRAYSIZE(tszTime), tszTemp );
nHours = 0;
nMins = 0;
dwSeconds = ( DWORD )( cnsFileDuration / 10000000 );
nHours = dwSeconds / 60 / 60;
dwSeconds %= 3600;
nMins = dwSeconds / 60;
dwSeconds %= 60;
if( 0 != nHours )
{
(void)StringCchPrintf( tszTemp, ARRAYSIZE(tszTemp), _T( "%d:" ), nHours );
(void)StringCchCat( tszTime, ARRAYSIZE(tszTime), tszTemp );
}
(void)StringCchPrintf( tszTemp, ARRAYSIZE(tszTemp), _T( "%02d:%02d" ), nMins, dwSeconds );
(void)StringCchCat( tszTime, ARRAYSIZE(tszTime), tszTemp );
SendDlgItemMessage( g_hwndDialog, IDC_SLIDER , TBM_SETPOS, TRUE, ( LONG )( cnsTimeElapsed / 10000 ) );
SendDlgItemMessage( g_hwndDialog, IDC_DURATION, WM_SETTEXT, 0, ( WPARAM )tszTime );
return;
}
示例9: DeleteRegKey
// удаляет ключ
void DeleteRegKey(HKEY hRoot,TCHAR *Key)
{
TCHAR FullKeyName[512];
StringCchCopy(FullKeyName,ARRAYSIZE(FullKeyName),PluginRootKey);
StringCchCat(FullKeyName,ARRAYSIZE(FullKeyName),(Key && *Key ? _T("\\"):_T("")));
StringCchCat(FullKeyName,ARRAYSIZE(FullKeyName),Key);
RegDeleteKey(hRoot,FullKeyName);
}
示例10: watcher
DWORD watcher(LPVOID arg) {
HANDLE heap = GetProcessHeap(), handle;
STARTUPINFO startupinfo;
LPPROCESS_INFORMATION cc_procinfo;
LPTSTR lpCmdLine = arg;
LPTSTR argv0;
LPTSTR srcpath;
LPTSTR cc_cmdline;
TCHAR tmpdir[MAX_PATH];
TCHAR fullExecutablePath[MAX_PATH];
PTSTR spc = StrChr(lpCmdLine, ' ');
if(spc == NULL) {
argv0 = HeapAlloc(heap, 0, lstrlen(lpCmdLine)+1);
StringCbCat(argv0, lstrlen(lpCmdLine), lpCmdLine);
} else {
argv0 = HeapAlloc(heap, 0, spc-lpCmdLine+1);
StringCbCat(argv0, spc-lpCmdLine, lpCmdLine);
}
GetModuleFileName(NULL, fullExecutablePath, MAX_PATH);
size_t len = lstrlen(fullExecutablePath)+1;
srcpath = HeapAlloc(heap, 0, len);
StringCbCat(srcpath, len-4, fullExecutablePath);
StringCchCat(srcpath, len, ".c");
printf("srcpath is \"%s\"\n", srcpath);
//WaitForSingleFile(srcpath, FILE_NOTIFY_LAST_WRITE);
ZeroMemory(&startupinfo, sizeof(STARTUPINFO));
startupinfo.cb = sizeof(STARTUPINFO);
size_t cclen = lstrlen(CC)+1+len-1+4+lstrlen(argv0)+1;
cc_cmdline = HeapAlloc(heap, 0, cclen);
StringCbCat(cc_cmdline, cclen, CC);
StringCchCat(cc_cmdline, cclen, " ");
StringCchCat(cc_cmdline, cclen, srcpath);
StringCchCat(cc_cmdline, cclen, " -o ");
StringCchCat(cc_cmdline, cclen, argv0);
printf("cc_cmdline is \"%s\"\n", cc_cmdline);
return 0;
CreateProcess(NULL, cc_cmdline, NULL, NULL, TRUE, 0,
NULL, NULL, &startupinfo, cc_procinfo);
HeapFree(heap, 0, argv0);
HeapFree(heap, 0, srcpath);
HeapFree(heap, 0, cc_cmdline);
WaitForSingleObject(cc_procinfo->hProcess, INFINITE);
printf("Execing...\n");
CreateProcess(NULL, lpCmdLine, NULL, NULL, TRUE, 0,
NULL, NULL, &startupinfo, cc_procinfo);
ExitProcess(0);
}
示例11: resolveGameStringSubStrings
/// Function name : resolveGameStringSubStrings
// Description : Expands sub-strings within the source-text and strips out any comments
//
// CONST GAME_STRING* pGameString : [in] GameString currently being resolved
// TCHAR* szOutput : [in/out] Output buffer
// CONST UINT iOutputLength : [in] Length of output buffer, in characters
// STACK* pHistoryStack : [in/out] Represents the 'chain' of GameStrings being resolved
// ERROR_QUEUE* pErrorQueue : [in/out] ErrorQueue, may already contain errors
//
// Return Value : Number of sub-strings that could not be resolved
//
UINT resolveGameStringSubStrings(CONST GAME_STRING* pGameString, TCHAR* szOutput, CONST UINT iOutputLength, STACK* pHistoryStack, ERROR_QUEUE* pErrorQueue)
{
SUBSTRING* pSubString; // SubString iterator
GAME_STRING* pSourceString; // First game string in the list
TCHAR* szPreview; // Preview text for error reporting
UINT iMissingSubstrings;
// Prepare
iMissingSubstrings = 0;
/// [CHECK] Ensure sub-string is not self-referencial
if (isValueInList(pHistoryStack, (LPARAM)pGameString))
{
// Lookup initial GameString
findListObjectByIndex(pHistoryStack, 0, (LPARAM&)pSourceString);
// [ERROR] "Circular sub-string references detected in page %u, string %u : '%s'"
generateQueuedError(pErrorQueue, HERE(IDS_GAME_STRING_SUBSTRING_RECURSIVE), pSourceString->iPageID, pSourceString->iID, szPreview = generateGameStringPreview(pGameString, 96));
utilDeleteString(szPreview);
return FALSE;
}
// Prepare
pSubString = createSubString(pGameString->szText);
/// [STACK] Add GameString to history stack
pushObjectOntoStack(pHistoryStack, (LPARAM)pGameString);
/// Iterate through sub-strings
while (findNextSubString(pGameString, pSubString, iMissingSubstrings, pHistoryStack, pErrorQueue))
{
// Examine type
switch (pSubString->eType)
{
/// [MISSION, TEXT] Append to output
case SST_MISSION:
case SST_LOOKUP:
case SST_TEXT:
StringCchCat(szOutput, MAX_STRING, pSubString->szText);
break;
/// [COMMENTS] Ignore
case SST_COMMENT:
// [SPECIAL CASE] Allow 'opening bracket' operator
if (utilCompareString(pSubString->szText, "("))
StringCchCat(szOutput, MAX_STRING, pSubString->szText);
break;
}
}
// [STACK] Remove GameString from processing stack
popObjectFromStack(pHistoryStack);
// Cleanup
deleteSubString(pSubString);
return iMissingSubstrings;
}
示例12: open_file
HANDLE
open_file(
__in char *filename
)
/*++
Routine Description:
Called by main() to open an instance of our device after obtaining its name
Arguments:
None
Return Value:
Device handle on success else NULL
--*/
{
int success = 1;
HANDLE h;
if ( !GetUsbDeviceFileName(
(LPGUID) &GUID_CLASS_USBSAMP_USB,
completeDeviceName) )
{
NOISY(("Failed to GetUsbDeviceFileName err - %d\n", GetLastError()));
return INVALID_HANDLE_VALUE;
}
(void) StringCchCat (completeDeviceName, MAX_LENGTH, "\\" );
if(FAILED(StringCchCat (completeDeviceName, MAX_LENGTH, filename))) {
NOISY(("Failed to open handle - possibly long filename\n"));
return INVALID_HANDLE_VALUE;
}
printf("completeDeviceName = (%s)\n", completeDeviceName);
h = CreateFile(completeDeviceName,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
if (h == INVALID_HANDLE_VALUE) {
NOISY(("Failed to open (%s) = %d", completeDeviceName, GetLastError()));
success = 0;
} else {
NOISY(("Opened successfully.\n"));
}
return h;
}
示例13: performXMLCharacterEntityReplacement
/// Function name : performXMLCharacterEntityReplacement
// Description :
//
// TCHAR* szInput : [in]
// CONST UINT iInputLength : [in]
//
// Return Value : New string length
//
UINT performXMLCharacterEntityReplacement(TCHAR* szInput, CONST UINT iInputLength)
{
CONST TCHAR *szPosition, // Current position
*szEntity, // Entity being parsed
*szSemiColon; // Semicolon marking the end of the entity
TCHAR *szBuffer, // Output Assembly buffer
szCharacter[2]; // Converted entity character as a string
// Prepare
szCharacter[1] = NULL;
szPosition = szInput;
// Create working buffer
szBuffer = utilCreateEmptyString(iInputLength);
/// [CHECK] Find next entity
while (szPosition AND (szEntity = utilFindSubString(szPosition, "&#")))
{
// Copy preceeding characters to output
if (szEntity - szPosition)
StringCchCatN(szBuffer, iInputLength, szPosition, szEntity - szPosition);
/// [CHECK] Find end marker
if (szSemiColon = utilFindCharacter(szEntity, ';'))
{
// [CHECK] Examine encoding type
if (szEntity[2] == 'x')
// [HEX] &#xhhhh
utilScanf(&szEntity[3], TEXT("%04x"), &szCharacter[0]);
else
// [DECIMAL] &#nnnn
szCharacter[0] = utilConvertStringToInteger(&szEntity[2]);
/// [FOUND] Append entity and update position
StringCchCat(szBuffer, iInputLength, szCharacter);
szPosition = &szSemiColon[1];
}
else
{
/// [NOT FOUND] Copy marker and remainder of string to the output buffer
StringCchCat(szBuffer, iInputLength, szEntity);
szPosition = NULL;
}
}
/// [COMPLETE] Overwrite input buffer
StringCchCopy(szInput, iInputLength, szBuffer);
/// Append remainder of string
if (szPosition)
StringCchCat(szInput, iInputLength, szPosition);
// Cleanup and return length
utilDeleteString(szBuffer);
return lstrlen(szInput);
}
示例14: MAKEINTRESOURCE
INT_PTR CAboutDialog::OnInitDialog()
{
m_hIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(0),
MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,
32,32,LR_VGACOLOR));
SendMessage(m_hDlg,WM_SETICON,ICON_SMALL,reinterpret_cast<LPARAM>(m_hIcon));
/* If the dialog has been loaded from a resource other than
the one in the executable (which will be the case, for example,
if a translation DLL has been loaded), then the image that
normally appears won't be shown. This is because the static
control will attempt to load it from its resource section (where
the image doesn't exist). Manually set the image here. */
if(GetInstance() != GetModuleHandle(0))
{
HBITMAP hbm = LoadBitmap(GetModuleHandle(0),MAKEINTRESOURCE(IDB_ABOUT));
SendDlgItemMessage(m_hDlg,IDC_ABOUT_STATIC_IMAGE,STM_SETIMAGE,
IMAGE_BITMAP,reinterpret_cast<LPARAM>(hbm));
}
TCHAR szVersion[64];
TCHAR szBuild[64];
TCHAR szBuildDate[64];
TCHAR szTemp[64];
/* Indicate which architecture (32-bit or
64-bit) we are building for in the version
string.*/
#ifdef WIN64
LoadString(GetInstance(),IDS_ABOUT_64BIT_BUILD,
szBuild,SIZEOF_ARRAY(szBuild));
#else
LoadString(GetInstance(),IDS_ABOUT_32BIT_BUILD,
szBuild,SIZEOF_ARRAY(szBuild));
#endif
LoadString(GetInstance(),IDS_ABOUT_UNICODE_BUILD,
szTemp,SIZEOF_ARRAY(szTemp));
StringCchCat(szBuild,SIZEOF_ARRAY(szBuild),_T(" "));
StringCchCat(szBuild,SIZEOF_ARRAY(szBuild),szTemp);
GetDlgItemText(m_hDlg,IDC_STATIC_VERSIONNUMBER,szTemp,SIZEOF_ARRAY(szTemp));
StringCchPrintf(szVersion,SIZEOF_ARRAY(szVersion),szTemp,VERSION_STRING_W,szBuild);
SetDlgItemText(m_hDlg,IDC_STATIC_VERSIONNUMBER,szVersion);
GetDlgItemText(m_hDlg,IDC_STATIC_BUILDDATE,szTemp,SIZEOF_ARRAY(szTemp));
StringCchPrintf(szBuildDate,SIZEOF_ARRAY(szBuildDate),szTemp,BUILD_DATE_STRING);
SetDlgItemText(m_hDlg,IDC_STATIC_BUILDDATE,szBuildDate);
CenterWindow(GetParent(m_hDlg),m_hDlg);
return TRUE;
}
示例15: GetLastError
// ---------------------------------------------
// Append the text to the logging window
// ---------------------------------------------
VOID CGreenPrintWindowLogging::Log( LPWSTR Text )
{
DWORD ErrorCode = GetLastError();
if ( NULL != Text && NULL != m_hWndEdit )
{
SYSTEMTIME CurrentTimeUTC;
GetSystemTime( &CurrentTimeUTC );
SYSTEMTIME CurrentTimeLocal;
SystemTimeToTzSpecificLocalTime( NULL, &CurrentTimeUTC, &CurrentTimeLocal );
WCHAR TimeText[ 128 ] = { 0 };
StringCchPrintf( TimeText, _countof(TimeText), L"%02d/%02d/%d %02d:%02d:%02d: ",
CurrentTimeLocal.wMonth, CurrentTimeLocal.wDay, CurrentTimeLocal.wYear,
CurrentTimeLocal.wHour, CurrentTimeLocal.wMinute, CurrentTimeLocal.wSecond );
WCHAR ErrorText[ 64 ] = { 0 };
if ( NO_ERROR != ErrorCode )
{
StringCchPrintf( ErrorText, _countof(ErrorText), L" (%d)", ErrorCode );
}
WCHAR *NewLine = L"\r\n";
DWORD cchNewText = GetWindowTextLength( m_hWndEdit ) + wcslen(TimeText) + wcslen(Text) + wcslen(ErrorText) + wcslen(NewLine) + 1;
WCHAR *NewText = (WCHAR*)LocalAlloc( LMEM_ZEROINIT, cchNewText * sizeof(WCHAR) );
if ( NULL != NewText )
{
GetWindowText( m_hWndEdit, NewText, cchNewText );
if ( SUCCEEDED( StringCchCat( NewText, cchNewText, TimeText ) ) )
{
if ( SUCCEEDED( StringCchCat( NewText, cchNewText, Text ) ) )
{
if ( SUCCEEDED( StringCchCat( NewText, cchNewText, ErrorText ) ) )
{
if ( SUCCEEDED( StringCchCat( NewText, cchNewText, NewLine ) ) )
{
SetWindowText( m_hWndEdit, NewText );
}
}
}
}
LocalFree( NewText );
NewText = NULL;
}
}
}