当前位置: 首页>>代码示例>>C++>>正文


C++ StringCchPrintf函数代码示例

本文整理汇总了C++中StringCchPrintf函数的典型用法代码示例。如果您正苦于以下问题:C++ StringCchPrintf函数的具体用法?C++ StringCchPrintf怎么用?C++ StringCchPrintf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StringCchPrintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PerflogReadModuleLevel

VOID
PerflogReadModuleLevel(
    HINSTANCE hInstance
)
{
    LONG lReturn;                   // Create key return value
    TCHAR szInfo[iDEBUGINFO];       // Constructs key names
    TCHAR szFullName[iDEBUGINFO];   // Load the full path and module name
    HKEY hModuleKey;                // Module key handle
    LPTSTR pName;                   // Searches from the end for a backslash
    DWORD dwKeySize, dwKeyType, dwKeyValue;

    DWORD dwSize = GetModuleFileName(
                       (hInstance ? hInstance : GetModuleHandle(NULL)),
                       szFullName,
                       iDEBUGINFO);

    if(0 == dwSize || iDEBUGINFO == dwSize)
    {
        return;
    }

    pName = _tcsrchr(szFullName, '\\');
    if(pName == NULL)
    {
        pName = szFullName;
    }
    else
    {
        pName++;
    }

    /* Construct the base key name */
    (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("SOFTWARE\\Debug\\%s"), pName);

    /* Open the key for this module */
    lReturn =
        RegOpenKeyEx(
            HKEY_LOCAL_MACHINE,   // Handle of an open key
            szInfo,               // Address of subkey name
            (DWORD) 0,            // Reserved value
            KEY_QUERY_VALUE,      // Desired security access
            &hModuleKey);         // Opened handle buffer

    if(lReturn != ERROR_SUCCESS)
    {
        return;
    }

    dwKeySize = sizeof(DWORD);
    lReturn = RegQueryValueEx(
                  hModuleKey,                 // Handle to an open key
                  TEXT("PERFLOG"),
                  NULL,                       // Reserved field
                  &dwKeyType,                 // Returns the field type
                  (LPBYTE) &dwKeyValue,       // Returns the field's value
                  &dwKeySize);                // Number of bytes transferred

    if((lReturn == ERROR_SUCCESS) && (dwKeyType == REG_DWORD))
    {
        PerflogModuleLevel = dwKeyValue;
    }

    RegCloseKey(hModuleKey);
}
开发者ID:PanjiNamjaElf,项目名称:vsfiltermod,代码行数:65,代码来源:perflog.cpp

示例2: DlgProc

INT_PTR CALLBACK DlgProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	switch (msg)
	{
		case WM_INITDIALOG:
		{
#ifndef _APP_NO_DARKTHEME
			_r_wnd_setdarktheme (hwnd);
#endif // _APP_NO_DARKTHEME

			// configure listview
			_r_listview_setstyle (hwnd, IDC_LISTVIEW, LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_LABELTIP);

			_r_listview_addcolumn (hwnd, IDC_LISTVIEW, 1, nullptr, 39, LVCFMT_LEFT);
			_r_listview_addcolumn (hwnd, IDC_LISTVIEW, 2, nullptr, 61, LVCFMT_RIGHT);

			for (UINT i = 0; i < TypeMax; i++)
				_r_listview_additem (hwnd, IDC_LISTVIEW, i, 0, nullptr);

			// configure datetime format
			{
				WCHAR date_format[MAX_PATH] = {0};
				WCHAR time_format[MAX_PATH] = {0};

				if (
					GetLocaleInfo (LOCALE_SYSTEM_DEFAULT, LOCALE_SLONGDATE, date_format, _countof (date_format)) &&
					GetLocaleInfo (LOCALE_SYSTEM_DEFAULT, LOCALE_STIMEFORMAT, time_format, _countof (time_format))
					)
				{
					WCHAR buffer[MAX_PATH] = {0};
					StringCchPrintf (buffer, _countof (buffer), L"%s %s", date_format, time_format);

					SendDlgItemMessage (hwnd, IDC_INPUT, DTM_SETFORMAT, 0, (LPARAM)buffer);
				}
			}

			// print latest timestamp
			{
				SYSTEMTIME st = {0};

				current_timestamp_utc = app.ConfigGet (L"LatestTimestamp", _r_unixtime_now ()).AsLonglong ();

				//_app_gettime (current_timestamp_utc, 0, &st);
				//_app_printdate (hwnd, &st);
			}

			_r_ctrl_settip (hwnd, IDC_CURRENT, LPSTR_TEXTCALLBACK);

			break;
		}

		case WM_DESTROY:
		{
			// save latest timestamp
			{
				SYSTEMTIME st = {0};
				//SendDlgItemMessage (hwnd, IDC_INPUT, DTM_GETSYSTEMTIME, 0, (LPARAM)&st);

				_app_gettime (current_timestamp_utc, 0, &st);

				app.ConfigSet (L"LatestTimestamp", _r_unixtime_from_systemtime (&st));
			}

			PostQuitMessage (0);

			break;
		}

		case RM_INITIALIZE:
		{
			// configure menu
			CheckMenuItem (GetMenu (hwnd), IDM_ALWAYSONTOP_CHK, MF_BYCOMMAND | (app.ConfigGet (L"AlwaysOnTop", false).AsBool () ? MF_CHECKED : MF_UNCHECKED));
			CheckMenuItem (GetMenu (hwnd), IDM_CHECKUPDATES_CHK, MF_BYCOMMAND | (app.ConfigGet (L"CheckUpdates", true).AsBool () ? MF_CHECKED : MF_UNCHECKED));
			CheckMenuItem (GetMenu (hwnd), IDM_CLASSICUI_CHK, MF_BYCOMMAND | (app.ConfigGet (L"ClassicUI", _APP_CLASSICUI).AsBool () ? MF_CHECKED : MF_UNCHECKED));

			// configure timezone
			{
				const HMENU submenu_timezone = GetSubMenu (GetSubMenu (GetMenu (hwnd), 1), TIMEZONE_MENU);

				// clear menu
				for (UINT i = 0;; i++)
				{
					if (!DeleteMenu (submenu_timezone, TIMEZONE_MENU + i, MF_BYCOMMAND))
					{
						DeleteMenu (submenu_timezone, 0, MF_BYPOSITION); // delete separator
						break;
					}
				}

				const LONG current_bias = _app_getcurrentbias ();
				const LONG default_bias = _app_getdefaultbias ();

				for (size_t i = 0; i < _countof (int_timezones); i++)
				{
					const LONG bias = int_timezones[i];

					MENUITEMINFO mii = {0};

					WCHAR menu_title[32] = {0};
					StringCchPrintf (menu_title, _countof (menu_title), L"GMT %s", _app_timezone2string (bias, true, L"+00:00 (UTC)").GetString ());
//.........这里部分代码省略.........
开发者ID:henrypp,项目名称:timevertor,代码行数:101,代码来源:main.cpp

示例3: SHGetPathFromIDList

BOOL MainWindow::OpenProjData()
{
	RootDicomObj *DCMinfo = NULL;
	char filename[MAX_PATH];
	char projFolder[MAX_PATH];

	BROWSEINFO bi = {0};
	PIDLIST_ABSOLUTE pidl;

	WCHAR szDisplayName[MAX_PATH];
	WCHAR szTitle[] = L"Select a folder containing projection data.";

	HANDLE hFindFile;
	WCHAR szFileName[MAX_PATH];
	WIN32_FIND_DATA findData = {0};

	if(m_Recon && !m_ReconSaved)
		if(MessageBox(m_hwnd,
			L"Reconstruction has not been saved. Do you wish to continue?",
			L"WinCone CT",
			MB_ICONWARNING | MB_YESNO) == IDNO)
			return FALSE;

	bi.hwndOwner = m_hwnd;
	bi.pidlRoot = NULL;
	bi.pszDisplayName = szDisplayName;
	bi.lpszTitle = szTitle;
	bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_NONEWFOLDERBUTTON | BIF_RETURNONLYFSDIRS;
	bi.lpfn = NULL;

	if(!(pidl = SHBrowseForFolder(&bi)))
		return FALSE;

	SHGetPathFromIDList(pidl, szDisplayName);

	// do _findfirst() stuff with current directory
	StringCchPrintf(szFileName,MAX_PATH,L"%s\\%s",szDisplayName,L"1.3.6.1.4.1*");
	hFindFile = FindFirstFile(szFileName,&findData);

	if(hFindFile == INVALID_HANDLE_VALUE)
	{
		MessageBox(m_hwnd,
			L"The selected folder does not contain valid DICOM projection data.",
			L"Load Projection Data",
			MB_OK);
		return FALSE;
	}

	FindClose(hFindFile);

	sprintf_s(filename,sizeof(filename),"%S\\%S",szDisplayName,findData.cFileName);
	DCMinfo = new RootDicomObj(filename,true);
	// confirm that DICOM files are legit here

	if(m_Recon)
	{
		delete m_Recon;
		m_Recon = NULL;
	}
	if(m_Proj)
	{
		delete m_Proj;
		m_Proj = NULL;
	}

	// Update the current folder field
	SendMessage(m_hCurrentFolder,WM_SETTEXT,NULL,(LPARAM)szDisplayName);

	// Enable the reconstruction controls

	delete DCMinfo;

	WideCharToMultiByte(1251,WC_NO_BEST_FIT_CHARS,szDisplayName,MAX_PATH,projFolder,sizeof(projFolder),0,NULL);
	m_Proj = new Projection(projFolder);
	SendMessage(m_hProgress,PBM_SETRANGE,MAKEWPARAM(0,0),MAKELPARAM(0,m_Proj->GetNumProj()));

	return TRUE;
}
开发者ID:JStrydhorst,项目名称:win-cone-ct,代码行数:78,代码来源:win_cone_ct.cpp

示例4: _DeleteAllResourceData

void CResourceMapDoc::Serialize(CArchive& ar)
{
    if (ar.IsStoring())
    {
        // There is nothing to save.
        int x = 0;
    }
    else
    {
        CFile *pFile = ar.GetFile();

        // Set the current directory, so we know where to look for the resource files.
        // If not, clicking on an item in the recent documents list won't work
        CString path = pFile->GetFilePath();
        path.MakeLower();
        int iFileOffset = path.Find(TEXT("\\resource.map"));
        if (iFileOffset > 0)
        {
            path.SetAt(iFileOffset, 0); // Null terminate it

            // Set this folder as our new game folder
            CResourceMap &map = theApp.GetResourceMap();
            map.SetGameFolder(path);

            // Close it.  We only wanted the path.
            pFile->Close();

            // Clear the current view.
            _DeleteAllResourceData();
            _DeleteAllPics();

            CResourceEnumerator *pEnum;
            if (SUCCEEDED(map.CreateEnumerator(RTF_PIC, &pEnum)))
            {
                CResourceData *pData;
                while (S_OK == pEnum->Next(&pData))
                {
                    // TODO: try catch, and free pData?

                    // Add these resource datas.
                    _resources.Add(pData);

                    // And create a pic from them.
                    CPic *ppic = new CPic();
                    if (ppic)
                    {
                        if (SUCCEEDED(ppic->InitFromResource(pData)))
                        {
                            _pics.Add(ppic);
                        }
                        else
                        {
                            delete ppic;
                        }
                    }
                }

#ifdef DEBUG
                INT_PTR iSizeMemory = 0;
                for (INT_PTR i = 0; i < _pics.GetSize(); i++)
                {
                    CPic *ppic = _pics.GetAt(i);
                    iSizeMemory += ppic->GetMemorySize();
                }
                TCHAR sz[MAX_PATH];
                StringCchPrintf(sz, ARRAYSIZE(sz), TEXT("Memory size of pics: %d"), iSizeMemory);
                OutputDebugString(sz);
#endif 

                SetModifiedFlag(TRUE);
                UpdateAllViews(NULL, VIEWUPDATEHINT_RESOURCEMAPCHANGED);

                delete pEnum;
            }

        }
        else
        {
            AfxMessageBox(TEXT("SCI game resources must be called resource.map"), MB_OK | MB_ICONEXCLAMATION);
        }
    }
}
开发者ID:OmerMor,项目名称:SciCompanion,代码行数:82,代码来源:SCIPicEditorDoc.cpp

示例5: JpqlpcCreatePort

NTSTATUS JpqlpcCreatePort(
	__in PWSTR Name,
	__in PSECURITY_ATTRIBUTES SecurityAttributes,
	__in ULONG SharedMemorySize,
	__out JPQLPC_PORT_HANDLE *PortHandle,
	__out PBOOL OpenedExisting
	)
{
	NTSTATUS Status = STATUS_UNSUCCESSFUL;
	PJPQLPC_PORT Port = NULL;
	WCHAR ServerEventName[ JPQLPC_MAX_PORT_NAME_CCH + 10 ];
	WCHAR ClientEventName[ JPQLPC_MAX_PORT_NAME_CCH + 10 ];
	size_t NameLen;

	ULONG AllocGranularity = JpqlpcsGetAllocationGranularity();

	if ( ! Name ||
		 SharedMemorySize == 0 ||
		 ! PortHandle ||
		 ( SharedMemorySize % AllocGranularity ) != 0 ||
		 ! OpenedExisting )
	{
		return STATUS_INVALID_PARAMETER;
	}

	if ( FAILED( StringCchLength(
		Name,
		JPQLPC_MAX_PORT_NAME_CCH,
		&NameLen ) ) ||
		NameLen == 0 ||
		NameLen >= JPQLPC_MAX_PORT_NAME_CCH )
	{
		return STATUS_INVALID_PARAMETER;
	}

	*OpenedExisting = FALSE;

	//
	// Generate names for events.
	//
	if ( FAILED( StringCchPrintf(
		ServerEventName,
		_countof( ServerEventName ),
		L"%s_Server",
		Name ) ) )
	{
		return NTSTATUS_QLPC_CANNOT_CREATE_PORT;
	}

	if ( FAILED( StringCchPrintf(
		ClientEventName,
		_countof( ClientEventName ),
		L"%s_Client",
		Name ) ) )
	{
		return NTSTATUS_QLPC_CANNOT_CREATE_PORT;
	}

	//
	// Allocate port struct.
	//
	Port = ( PJPQLPC_PORT ) malloc( sizeof( JPQLPC_PORT ) );
	if ( ! Port )
	{
		return STATUS_NO_MEMORY;
	}

	ZeroMemory( Port, sizeof( JPQLPC_PORT ) );

	//
	// Allocate pagefile-backed shared memory.
	//
	Port->SharedMemory.Size = SharedMemorySize;
	Port->SharedMemory.FileMapping = CreateFileMapping(
		INVALID_HANDLE_VALUE,
		SecurityAttributes,
		PAGE_READWRITE,
		0,
		SharedMemorySize,
		Name );
	if ( Port->SharedMemory.FileMapping == NULL )
	{
		switch ( GetLastError() )
		{
		case ERROR_ACCESS_DENIED:
			Status = STATUS_ACCESS_VIOLATION;
		case ERROR_INVALID_HANDLE:
			Status = STATUS_OBJECT_NAME_COLLISION;
		default:
			Status = NTSTATUS_QLPC_CANNOT_CREATE_PORT;
		}

		goto Cleanup;
	}
	else
	{
		if ( ERROR_ALREADY_EXISTS == GetLastError() )
		{
			*OpenedExisting = TRUE;
		}
//.........这里部分代码省略.........
开发者ID:jpassing,项目名称:ntrace,代码行数:101,代码来源:port.c

示例6: NdasUpdateGetUpdateInfo

NDUPDATE_API
BOOL
WINAPI
NdasUpdateGetUpdateInfo(
	IN IBindStatusCallback* pBSC,
	IN LPCTSTR szBaseURL,
	IN PNDUPDATE_SYSTEM_INFO pSystemInformation,
	OUT PNDUPDATE_UPDATE_INFO_V2 pUpdateInformation)
{
	BOOL  fSuccess = FALSE;
	HRESULT hr = E_FAIL;

	DBGPRT_INFO(_FT("BaseURL: %s\n"), szBaseURL);

	TCHAR szUpdateURL[NDUPDATE_MAX_URL];

	if (IsBadReadPtr(pSystemInformation, sizeof(NDUPDATE_SYSTEM_INFO)) ||
		IsBadWritePtr(pUpdateInformation, sizeof(NDUPDATE_UPDATE_INFO_V2)))
	{
		SetLastError(ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	// create URL
	hr = StringCchPrintf(
		szUpdateURL,
		NDUPDATE_MAX_URL,
		_T("%s?REV=%d&PLATFORM=%d&MAJOR=%d&MINOR=%d&BUILD=%d&PRIV=%d&VENDOR=%d&LANGUAGESET=%d&CT=%08X"),
		szBaseURL,
		NDAS_UPDATE_REV,
		pSystemInformation->dwPlatform,
		pSystemInformation->ProductVersion.wMajor,
		pSystemInformation->ProductVersion.wMinor,
		pSystemInformation->ProductVersion.wBuild,
		pSystemInformation->ProductVersion.wPrivate,
		pSystemInformation->dwVendor,
		pSystemInformation->dwLanguageSet,
		GetTickCount());

	if (FAILED(hr)) {
		DBGPRT_ERR_EX(_FT("Making URL failed, too long?, hr=%08X: "), hr);
		return FALSE;
	}

	DBGPRT_INFO(_FT("UpdateURL: %s\n"), szUpdateURL);

	TCHAR szDownloadedFileName[MAX_PATH] = {0};
	hr = ::URLDownloadToCacheFile(
		NULL,
		szUpdateURL,
		szDownloadedFileName,
		sizeof(szDownloadedFileName),
		0,
		pBSC);

	if (FAILED(hr)) {
		DBGPRT_ERR_EX(_FT("Downloading a file failed.\n"));
		::SetLastError(hr);
		return FALSE;
	}

	DBGPRT_INFO(_FT("Downloaded to %s.\n"), szDownloadedFileName);

	TCHAR szINIFileName[MAX_PATH];
	TCHAR szINIString[NDUPDATE_STRING_SIZE] = {0};  
	UINT uiINIValue;

	GetPrivateProfileString(
		UPDATER_SECTION, 
		_T("CLASS"), 
		_T(""), 
		szINIString, 
		NDUPDATE_STRING_SIZE, 
		szDownloadedFileName);

	DBGPRT_INFO(_T("UPDATER CLASS: %s\n"), szINIString);

	if (0 != lstrcmpi(szINIString, UPDATE_CLASS_STRING)) {
		SetLastError(NDUPDATE_ERROR_INVALID_SERVER_RESPONSE);
		return FALSE;
	}

	uiINIValue = ::GetPrivateProfileInt(
		UPDATER_SECTION, 
		_T("REVISION"), 
		0, 
		szDownloadedFileName);

	DBGPRT_INFO(_T("UPDATER REVISION: %d\n"), uiINIValue);

	if (NDAS_UPDATE_REV != uiINIValue) {
		SetLastError(NDUPDATE_ERROR_INVALID_UPDATE_VERSION_FROM_SERVER);
		return FALSE;
	}

	// read patch information
	uiINIValue = ::GetPrivateProfileInt(
		UPDATE_SECTION, 
		_T("NEED_UPDATE"), 
		0xFFFFFFFF,
//.........这里部分代码省略.........
开发者ID:yzx65,项目名称:ndas4windows,代码行数:101,代码来源:ndupdate.cpp

示例7: PerfUpdateCountersReport

VOID
PerfUpdateCountersReport(
	IN HWND hWndCounters,
	IN PPERF_TASK_CONTEXT TaskContext 
	)
{
	PPERF_INFORMATION Perf;
	LVITEM item = {0};
	WCHAR Buffer[MAX_PATH];
	double IoTotal;
	double Value;

	Perf = &TaskContext->Information;

	//
	// PerfCounterCpuTotal
	//

	item.mask = LVIF_TEXT;
	item.iItem = PerfCounterCpuTotal;

	item.iSubItem = PerfColumnValue;
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%.2f", Perf->CpuTotalUsage * 100); 
	StringCchCat(Buffer, MAX_PATH - 1, L"%");
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	item.iSubItem = PerfColumnAverage;
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%.2f", TaskContext->CpuHistory.Average); 
	StringCchCat(Buffer, MAX_PATH - 1, L"%");
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	item.iSubItem = PerfColumnMaximum;
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%.2f", TaskContext->CpuHistory.MaximumValue);
	StringCchCat(Buffer, MAX_PATH - 1, L"%");
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	//
	// PerfCounterPrivateBytes
	//

	item.iItem = PerfCounterPrivateBytes;

	item.iSubItem = PerfColumnValue;
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%.2f MB", 
		           (Perf->PrivateDelta.Value * 1.0) / (1024 * 1024 * 1.0)); 
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	item.iSubItem = PerfColumnAverage;
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%.2f MB", 
		            (TaskContext->MemoryHistory.Average * 1.0) / (1024 * 1024 * 1.0)); 
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	item.iSubItem = PerfColumnMaximum;
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%.2f MB", 
		            (TaskContext->MemoryHistory.MaximumValue * 1.0) / (1024 * 1024 * 1.0)); 
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	//
	// PerfCounterWorkingSet
	//

	item.iItem = PerfCounterWorkingSet;

	item.iSubItem = PerfColumnValue;
	Value = (Perf->WorkingSetDelta.Value * 1.0) / ((1024 * 1024) * 1.0);
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%.2f MB", Value); 
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	item.iSubItem = PerfColumnAverage;
	item.pszText = L"N/A";
	ListView_SetItem(hWndCounters, &item);

	item.iSubItem = PerfColumnMaximum;
	Value = (Perf->WorkingSetPeak * 1.0) / ((1024 * 1024) * 1.0);
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%.2f MB", Value); 
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	//
	// PerfCounterKernelHandles
	//

	item.iItem = PerfCounterKernelHandles;

	item.iSubItem = PerfColumnValue;
	StringCchPrintf(Buffer, MAX_PATH - 1, L"%u", Perf->KernelHandles); 
	item.pszText = Buffer;
	ListView_SetItem(hWndCounters, &item);

	item.iSubItem = PerfColumnAverage;
	item.pszText = L"N/A";
	ListView_SetItem(hWndCounters, &item);

//.........这里部分代码省略.........
开发者ID:HeckMina,项目名称:dprofiler,代码行数:101,代码来源:perfdlg.c

示例8: view_gettext

/*
 * return the text associated with a given column of a given row.
 * Return a pointer that does not need to be freed after use - ie
 * a pointer into our data somewhere, not a copy
 */
LPSTR
view_gettext(VIEW view, long row, int col)
{
    int line;
    int state;
    LPSTR pstr;
    HRESULT hr;

    pstr = NULL;   /* kill spurious diagnostic */
    if (view == NULL) {
        return(NULL);
    }

    ViewEnter();

    if ((0 > row) || (row >= view->rows)) {
        ViewLeave();
        return(NULL);
    }

    if (view->bExpand) {
        /* we are in expand mode */

        state = section_getstate(view->pLines[row].section);

        switch (col) {
        case 0:
            /* row nr */

            /* line numbers can be from either original file
             * this is a menu-selectable option
             */
            line = 0;
            switch (line_numbers) {
            case IDM_NONRS:
                pstr = NULL;
                break;

            case IDM_LNRS:
                line = view->pLines[row].nr_left;
                if (state == STATE_MOVEDRIGHT
                    || state == STATE_SIMILARRIGHT) {
                    line = -line;
                }
                break;

            case IDM_RNRS:
                line = view->pLines[row].nr_right;
                if (state == STATE_MOVEDLEFT
                    || state == STATE_SIMILARLEFT) {
                    line = -line;
                }
                break;
            }
            if (line == 0) {
                ViewLeave();
                return(NULL);
            }

            if (line < 0) {
                /* lines that are moved appear twice.
                 * show the correct-sequence line nr
                 * for the out-of-seq. copy in brackets.
                 */
                hr = StringCchPrintf(view->nrtext, 12, "(%d)", abs(line));
                if (FAILED(hr)) {
                    OutputError(hr, IDS_SAFE_PRINTF);
                    return(NULL);
                }

            } else {
                hr = StringCchPrintf(view->nrtext, 12, "%d", line);
                if (FAILED(hr)) {
                    OutputError(hr, IDS_SAFE_PRINTF);
                    return(NULL);
                }
            }
            pstr = view->nrtext;
            break;

        case 1:
            /* tag text - represents the state of the line */


            switch (state) {
            case STATE_SAME:
                pstr = "    ";
                break;

            case STATE_LEFTONLY:
            case STATE_SIMILARLEFT:
                pstr = " <! ";
                break;

            case STATE_RIGHTONLY:
//.........这里部分代码省略.........
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,代码来源:view.cpp

示例9: AMovieSetupRegisterServer

STDAPI
AMovieSetupRegisterServer( CLSID   clsServer
                         , LPCWSTR szDescription
                         , LPCWSTR szFileName
                         , LPCWSTR szThreadingModel = L"Both"
                         , LPCWSTR szServerType     = L"InprocServer32" )
{
  // temp buffer
  //
  TCHAR achTemp[MAX_PATH];

  // convert CLSID uuid to string and write
  // out subkey as string - CLSID\{}
  //
  OLECHAR szCLSID[CHARS_IN_GUID];
  HRESULT hr = StringFromGUID2( clsServer
                              , szCLSID
                              , CHARS_IN_GUID );
  ASSERT( SUCCEEDED(hr) );

  // create key
  //
  HKEY hkey;

  (void)StringCchPrintf( achTemp, NUMELMS(achTemp), CLSID_KEY_FORMAT_STRING, szCLSID );
  
  LONG lreturn = RegCreateKey( HKEY_CLASSES_ROOT
                             , (LPCTSTR)achTemp
                             , &hkey              );
  if( ERROR_SUCCESS != lreturn )
  {
    return AmHresultFromWin32(lreturn);
  }

  // set description string
  //

  (void)ConvertUnicodeStringToTCHARString( achTemp, NUMELMS(achTemp), szDescription );
  lreturn = RegSetValue( hkey
                       , (LPCTSTR)NULL
                       , REG_SZ
                       , achTemp
                       , sizeof(achTemp) );
  if( ERROR_SUCCESS != lreturn )
  {
    RegCloseKey( hkey );
    return AmHresultFromWin32(lreturn);
  }

  // create CLSID\\{"CLSID"}\\"ServerType" key,
  // using key to CLSID\\{"CLSID"} passed back by
  // last call to RegCreateKey().
  //
  HKEY hsubkey;

  (void)ConvertUnicodeStringToTCHARString( achTemp, NUMELMS(achTemp), szServerType );
  lreturn = RegCreateKey( hkey
                        , achTemp
                        , &hsubkey     );
  if( ERROR_SUCCESS != lreturn )
  {
    RegCloseKey( hkey );
    return AmHresultFromWin32(lreturn);
  }

  // set Server string
  //
  (void)ConvertUnicodeStringToTCHARString( achTemp, NUMELMS(achTemp), szFileName );
  lreturn = RegSetValue( hsubkey
                       , (LPCTSTR)NULL
                       , REG_SZ
                       , (LPCTSTR)achTemp
                       , sizeof(TCHAR) * (lstrlen(achTemp)+1) );
  if( ERROR_SUCCESS != lreturn )
  {
    RegCloseKey( hkey );
    RegCloseKey( hsubkey );
    return AmHresultFromWin32(lreturn);
  }

  (void)ConvertUnicodeStringToTCHARString( achTemp, NUMELMS(achTemp), szThreadingModel );
  lreturn = RegSetValueEx( hsubkey
                         , TEXT("ThreadingModel")
                         , 0L
                         , REG_SZ
                         , (CONST BYTE *)achTemp
                         , sizeof(TCHAR) * (lstrlen(achTemp)+1) );

  // close hkeys
  //
  RegCloseKey( hkey );
  RegCloseKey( hsubkey );

  // and return
  //
  return HRESULT_FROM_WIN32(lreturn);

}
开发者ID:nobbk,项目名称:copo,代码行数:98,代码来源:dllsetup.cpp

示例10: ClearStream

void CExtentMonitorTextService::_DumpExtent(TfEditCookie ec, ITfContext *pContext, UINT nEventId)
{
    if (!_pMemStream)
        return;

    ClearStream(_pMemStream);

    switch (nEventId)
    {
        case DE_EVENTID_ACTIVATE:        
            AddStringToStream(_pMemStream, L"Event: Activate\r\n"); 
            break;
        case DE_EVENTID_ONSETFOCUS:
            AddStringToStream(_pMemStream, L"Event: OnSetFocus\r\n"); 
            break;
        case DE_EVENTID_ONENDEDIT:
            AddStringToStream(_pMemStream, L"Event: OnEndEdit\r\n"); 
            break;
        case DE_EVENTID_ONLAYOUTCHANGE:
            AddStringToStream(_pMemStream, L"Event: OnLayoutChange\r\n"); 
            break;
        case DE_EVENTID_FROMLANGUAGEBAR:
            AddStringToStream(_pMemStream, L"Event: From LanguageBar\r\n"); 
            break;
        default:
            AddStringToStream(_pMemStream, L"Event: Unknoen\r\n"); 
            break;
    }

    WCHAR sz[512];
    ITfContextView *pView = NULL;
    TF_SELECTION sel;

    memset(&_rcStartPos , 0, sizeof(RECT));
    memset(&_rcEndPos , 0, sizeof(RECT));
    memset(&_rcSelection , 0, sizeof(RECT));
    memset(&_rcView , 0, sizeof(RECT));

    if (SUCCEEDED(pContext->GetActiveView(&pView)))
    {
         ITfRange *pRange;
         RECT rc;
         BOOL fClipped;
         HWND hwnd;

         AddStringToStream(_pMemStream, L"Wnd Handle - ");
         if (SUCCEEDED(pView->GetWnd(&hwnd)))
         {
             WCHAR szWndClass[32];
             if (IsWindow(hwnd)) 
             {
                 GetClassNameW(hwnd, szWndClass, ARRAYSIZE(szWndClass));
                 StringCchPrintf(sz, ARRAYSIZE(sz), L"%08x %s\r\n", (DWORD)(ULONG_PTR)hwnd, szWndClass);
                 AddStringToStream(_pMemStream, sz);
             }
             else
             {
                 AddStringToStream(_pMemStream, L"null window handle\r\n");
             }
         }

         AddStringToStream(_pMemStream, L"Screen Ext\r\n");
         if (SUCCEEDED(pView->GetScreenExt(&rc)))
         {
             StringCchPrintf(sz, ARRAYSIZE(sz), L"    (%d, %d, %d, %d) - (%d, %d)\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top);
             AddStringToStream(_pMemStream, sz);
             _rcView = rc;
         }

         AddStringToStream(_pMemStream, L"Start Pos\r\n");
         if (SUCCEEDED(pContext->GetStart(ec, &pRange)))
         {
             if (SUCCEEDED(pView->GetTextExt(ec, pRange, &rc, &fClipped)))
             {
                 StringCchPrintf(sz, ARRAYSIZE(sz), L"    (%d, %d, %d, %d) - (%d, %d) %s\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");

                 AddStringToStream(_pMemStream, sz);
                 _rcStartPos = rc;
             }

             pRange->Release();
         }

         AddStringToStream(_pMemStream, L"End Pos\r\n");
         if (SUCCEEDED(pContext->GetEnd(ec, &pRange)))
         {
             if (SUCCEEDED(pView->GetTextExt(ec, pRange, &rc, &fClipped)))
             {
                 StringCchPrintf(sz, ARRAYSIZE(sz), L"    (%d, %d, %d, %d) - (%d, %d) %s\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");

                 AddStringToStream(_pMemStream, sz);
                 _rcEndPos = rc;
             }

             pRange->Release();
         }

         AddStringToStream(_pMemStream, L"Selection Pos\r\n");
         ULONG cFetched;
         if (SUCCEEDED(pContext->GetSelection(ec, 0, 1, &sel, &cFetched)))
//.........这里部分代码省略.........
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,代码来源:DumpExtent.cpp

示例11: ZeroMemory


//.........这里部分代码省略.........
          }
          else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2003, "));

          // Test for the server type.
          if ( osvi.wProductType != VER_NT_WORKSTATION )
          {
             if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
             {
                 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                    StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Edition for Itanium-based Systems" ));
                 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                    StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise Edition for Itanium-based Systems" ));
             }

             else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
             {
                 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                    StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter x64 Edition" ));
                 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                    StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise x64 Edition" ));
                 else StringCchCat(pszOS, BUFSIZE, TEXT( "Standard x64 Edition" ));
             }

             else
             {
                 if ( osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER )
                    StringCchCat(pszOS, BUFSIZE, TEXT( "Compute Cluster Edition" ));
                 else if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                    StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Edition" ));
                 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                    StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise Edition" ));
                 else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
                    StringCchCat(pszOS, BUFSIZE, TEXT( "Web Edition" ));
                 else StringCchCat(pszOS, BUFSIZE, TEXT( "Standard Edition" ));
             }
          }
       }

       if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
       {
          StringCchCat(pszOS, BUFSIZE, TEXT("Windows XP "));
          if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
             StringCchCat(pszOS, BUFSIZE, TEXT( "Home Edition" ));
          else StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
       }

       if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
       {
          StringCchCat(pszOS, BUFSIZE, TEXT("Windows 2000 "));

          if ( osvi.wProductType == VER_NT_WORKSTATION )
          {
             StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
          }
          else
          {
             if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
                StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Server" ));
             else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
                StringCchCat(pszOS, BUFSIZE, TEXT( "Advanced Server" ));
             else StringCchCat(pszOS, BUFSIZE, TEXT( "Server" ));
          }
       }

       // Eduardo: 2015-05-29
       // Remove essas informações que são desnecessárias
       return TRUE;

       // Include service pack (if any) and build number.

       //if( _tcslen(osvi.szCSDVersion) > 0 )
       if( size_t(wcslen(osvi.szCSDVersion)) > 0 )
       {
           StringCchCat(pszOS, BUFSIZE, TEXT(" ") );
           StringCchCat(pszOS, BUFSIZE, osvi.szCSDVersion);
       }

       TCHAR buf[80];

       StringCchPrintf( buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
       StringCchCat(pszOS, BUFSIZE, buf);

       if ( osvi.dwMajorVersion >= 6 )
       {
          if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
             StringCchCat(pszOS, BUFSIZE, TEXT( ", 64-bit" ));
          else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL )
             StringCchCat(pszOS, BUFSIZE, TEXT(", 32-bit"));
       }

       _tprintf(_T("OS Version Information %s\n"), pszOS);
       return TRUE;
    }

    else
    {
       printf( "This sample does not support this version of Windows.\n");
       return FALSE;
    }
}
开发者ID:lightbase,项目名称:cacic-agente,代码行数:101,代码来源:wcomputer.cpp

示例12: ShowWindow

void CSearchDialog::StartSearching()
{
	ShowWindow(GetDlgItem(m_hDlg, IDC_LINK_STATUS), SW_HIDE);
	ShowWindow(GetDlgItem(m_hDlg, IDC_STATIC_STATUS), SW_SHOW);

	m_AwaitingSearchItems.clear();
	m_SearchItemsMapInternal.clear();

	ListView_DeleteAllItems(GetDlgItem(m_hDlg, IDC_LISTVIEW_SEARCHRESULTS));

	TCHAR szBaseDirectory[MAX_PATH];
	TCHAR szSearchPattern[MAX_PATH];

	/* Get the directory and name, and remove leading and
	trailing whitespace. */
	/* TODO: Verify fields. */
	GetDlgItemText(m_hDlg, IDC_COMBO_DIRECTORY, szBaseDirectory,
		SIZEOF_ARRAY(szBaseDirectory));
	PathRemoveBlanks(szBaseDirectory);
	GetDlgItemText(m_hDlg, IDC_COMBO_NAME, szSearchPattern,
		SIZEOF_ARRAY(szSearchPattern));
	PathRemoveBlanks(szSearchPattern);

	BOOL bSearchSubFolders = IsDlgButtonChecked(m_hDlg, IDC_CHECK_SEARCHSUBFOLDERS) ==
		BST_CHECKED;

	BOOL bUseRegularExpressions = IsDlgButtonChecked(m_hDlg, IDC_CHECK_USEREGULAREXPRESSIONS) ==
		BST_CHECKED;

	BOOL bCaseInsensitive = IsDlgButtonChecked(m_hDlg, IDC_CHECK_CASEINSENSITIVE) ==
		BST_CHECKED;

	/* Turn search patterns of the form '???' into '*???*', and
	use this modified string to search. */
	if(!bUseRegularExpressions && lstrlen(szSearchPattern) > 0)
	{
		if(szSearchPattern[0] != '*' &&
			szSearchPattern[lstrlen(szSearchPattern) - 1] != '*')
		{
			TCHAR szTemp[MAX_PATH];

			StringCchPrintf(szTemp, SIZEOF_ARRAY(szTemp), _T("*%s*"),
				szSearchPattern);
			StringCchCopy(szSearchPattern, SIZEOF_ARRAY(szSearchPattern),
				szTemp);
		}
	}

	DWORD dwAttributes = 0;

	if(IsDlgButtonChecked(m_hDlg, IDC_CHECK_ARCHIVE) == BST_CHECKED)
		dwAttributes |= FILE_ATTRIBUTE_ARCHIVE;

	if(IsDlgButtonChecked(m_hDlg, IDC_CHECK_HIDDEN) == BST_CHECKED)
		dwAttributes |= FILE_ATTRIBUTE_HIDDEN;

	if(IsDlgButtonChecked(m_hDlg, IDC_CHECK_READONLY) == BST_CHECKED)
		dwAttributes |= FILE_ATTRIBUTE_READONLY;

	if(IsDlgButtonChecked(m_hDlg, IDC_CHECK_SYSTEM) == BST_CHECKED)
		dwAttributes |= FILE_ATTRIBUTE_SYSTEM;

	m_pSearch = new CSearch(m_hDlg, szBaseDirectory, szSearchPattern,
		dwAttributes, bUseRegularExpressions, bCaseInsensitive, bSearchSubFolders);
	m_pSearch->AddRef();

	/* Save the search directory and search pattern (only if they are not
	the same as the most recent entry). */
	BOOL bSaveEntry = FALSE;

	if(m_sdps->m_pSearchDirectories->empty() ||
		lstrcmp(szBaseDirectory, m_sdps->m_pSearchDirectories->begin()->c_str()) != 0)
	{
		bSaveEntry = TRUE;
	}

	if(bSaveEntry)
	{
		SaveEntry(IDC_COMBO_DIRECTORY, *m_sdps->m_pSearchDirectories);
	}

	bSaveEntry = FALSE;

	if(m_sdps->m_pSearchPatterns->empty() ||
		lstrcmp(szSearchPattern, m_sdps->m_pSearchPatterns->begin()->c_str()) != 0)
	{
		bSaveEntry = TRUE;
	}

	if(bSaveEntry)
	{
		SaveEntry(IDC_COMBO_NAME, *m_sdps->m_pSearchPatterns);
	}

	GetDlgItemText(m_hDlg, IDSEARCH, m_szSearchButton, SIZEOF_ARRAY(m_szSearchButton));

	TCHAR szTemp[64];

	LoadString(GetInstance(), IDS_STOP, szTemp, SIZEOF_ARRAY(szTemp));
	SetDlgItemText(m_hDlg, IDSEARCH, szTemp);
//.........这里部分代码省略.........
开发者ID:menghun3,项目名称:explorerplusplus,代码行数:101,代码来源:SearchDialog.cpp

示例13: ShowProcessInfo

VOID ShowProcessInfo(HWND hwnd, DWORD dwProcessID) {

   SetWindowText(hwnd, TEXT(""));   // Clear the output box

   CToolhelp th(TH32CS_SNAPALL, dwProcessID);

   // Show Process details
   PROCESSENTRY32 pe = { sizeof(pe) };
   BOOL fOk = th.ProcessFirst(&pe);
   for (; fOk; fOk = th.ProcessNext(&pe)) {
      if (pe.th32ProcessID == dwProcessID) {
         TCHAR szCmdLine[1024];
         if (GetProcessCmdLine(dwProcessID, szCmdLine, _countof(szCmdLine))) {
            AddText(hwnd, 
               TEXT("Command line: %s %s\r\n"), pe.szExeFile, szCmdLine);
         } else {
            AddText(hwnd, TEXT("Filename: %s\r\n"), pe.szExeFile);
         }
         AddText(hwnd, TEXT("   PID=%08X, ParentPID=%08X, ")
            TEXT("PriorityClass=%d, Threads=%d, Heaps=%d\r\n"),
            pe.th32ProcessID, pe.th32ParentProcessID, 
            pe.pcPriClassBase, pe.cntThreads,
            th.HowManyHeaps());
         TCHAR szOwner[MAX_PATH+1];
         if (GetProcessOwner(dwProcessID, szOwner, MAX_PATH)) {
            AddText(hwnd, TEXT("Owner: %s\r\n"), szOwner);
         }

         break;   // No need to continue looping
      }
   }


   // Show Modules in the Process
   // Number of characters to display an address
   AddText(hwnd, TEXT("\r\nModules Information:\r\n")
      TEXT("  Usage  %-*s(%-*s)  %10s  Module\r\n"),
      s_cchAddress, TEXT("BaseAddr"),
      s_cchAddress, TEXT("ImagAddr"), TEXT("Size"));

   MODULEENTRY32 me = { sizeof(me) };
   fOk = th.ModuleFirst(&me);
   for (; fOk; fOk = th.ModuleNext(&me)) {
      if (me.ProccntUsage == 65535) {
         // Module was implicitly loaded and cannot be unloaded
         AddText(hwnd, TEXT("  Fixed"));
      } else {
         AddText(hwnd, TEXT("  %5d"), me.ProccntUsage);
      }

      // Try to format the size in kb.
      TCHAR szFormattedSize[64];
      if (StrFormatKBSize(me.modBaseSize, szFormattedSize, 
         _countof(szFormattedSize)) == NULL)
      {
         StringCchPrintf(szFormattedSize, _countof(szFormattedSize), 
            TEXT("%10u"), me.modBaseSize); 
      }
      
      PVOID pvPreferredBaseAddr = 
         GetModulePreferredBaseAddr(pe.th32ProcessID, me.modBaseAddr);
      if (me.modBaseAddr == pvPreferredBaseAddr) {
         AddText(hwnd, TEXT("  %p %*s   %10s  %s\r\n"), 
            me.modBaseAddr, s_cchAddress, TEXT(""), 
            szFormattedSize, me.szExePath);
      } else {
         AddText(hwnd, TEXT("  %p(%p)  %10s  %s\r\n"), 
            me.modBaseAddr, pvPreferredBaseAddr, 
            szFormattedSize, me.szExePath);
      }
   }

   // Show threads in the process
   AddText(hwnd, TEXT("\r\nThread Information:\r\n")
      TEXT("      TID     Priority\r\n"));
   THREADENTRY32 te = { sizeof(te) };
   fOk = th.ThreadFirst(&te);
   for (; fOk; fOk = th.ThreadNext(&te)) {
      if (te.th32OwnerProcessID == dwProcessID) {
         int nPriority = te.tpBasePri + te.tpDeltaPri;
         if ((te.tpBasePri < 16) && (nPriority > 15)) nPriority = 15;
         if ((te.tpBasePri > 15) && (nPriority > 31)) nPriority = 31;
         if ((te.tpBasePri < 16) && (nPriority <  1)) nPriority =  1;
         if ((te.tpBasePri > 15) && (nPriority < 16)) nPriority = 16;
         AddText(hwnd, TEXT("   %08X       %2d\r\n"), 
            te.th32ThreadID, nPriority);
      }
   }
}
开发者ID:melvinvarkey,项目名称:ANCI_C_Training,代码行数:89,代码来源:ProcessInfo.cpp

示例14: Entrance

int Entrance(const wchar_t *CurDir, const wchar_t *PackName)
{
	int ret = 0;
	DWORD BytesRead;
	HANDLE hPack;
	struct ARC_HEADER ah;
	struct IDX idx;
	wchar_t MsgBuf[MAX_PATH], FileName[MAX_PATH];
	
	hPack = CreateFile(PackName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
	if (hPack == INVALID_HANDLE_VALUE)
	{
		StringCchPrintf(MsgBuf, MAX_PATH, L"无法打开文件%s\r\n", PackName);
		AppendMsg(MsgBuf);
		return -1;
	}

	DWORD idx_pointer = sizeof(ARC_HEADER);		
	DWORD end_of_idx;
	DWORD extract_file_num = 0;

	ReadFile(hPack, &ah.file_num, 4, &BytesRead, NULL);
	ReadFile(hPack, &ah.idx_length, 4, &BytesRead, NULL);

	end_of_idx = ah.idx_length + sizeof(ARC_HEADER);

	while (idx_pointer < end_of_idx)
	{
		SetFilePointer(hPack, idx_pointer, NULL, FILE_BEGIN);

		ReadFile(hPack, &idx.DataSize, 4, &BytesRead, NULL);
		ReadFile(hPack, &idx.DataOffset, 4, &BytesRead, NULL);
		idx.DataOffset += end_of_idx;			// 修正偏移地址

		int i = -1;
		do
		{
			ReadFile(hPack, &FileName[++i], 2, &BytesRead, NULL);
		}while (i<MAX_PATH-1 && FileName[i] != '\0');
		FileName[i] = 0;

		idx_pointer += sizeof(struct IDX) + 2 * (1 + wcslen(FileName));

		PVOID Data = VirtualAlloc(NULL, idx.DataSize, MEM_COMMIT, PAGE_READWRITE);
		if (!Data)
		{
			AppendMsg(L"内存不足!\r\n");
			CloseHandle(hPack);
			return -2;
		}

		SetFilePointer(hPack, idx.DataOffset, NULL, FILE_BEGIN);
		ReadFile(hPack, Data, idx.DataSize, &BytesRead, NULL);
		
		if (IsPnaFile((unsigned char*)Data))
		{
			ExtractPNAPFile((unsigned char*)Data, CurDir, FileName);
			++extract_file_num;
		}
		else if (!SplitFileNameAndSave(CurDir, FileName, Data, idx.DataSize))
			++extract_file_num;

		VirtualFree(Data, 0, MEM_RELEASE);
	}
	StringCchPrintf(MsgBuf, MAX_PATH, L"共提取文件(%d/%d)个   --   %s\r\n",
			extract_file_num, ah.file_num, PackName);
	AppendMsg(MsgBuf);
	return 0;
}
开发者ID:Kerisa,项目名称:ExtractGames,代码行数:69,代码来源:AdvHD.cpp

示例15: SqlTreeTableCreate

/*!
	ツリーのテーブルの存在を確認して、なかったら作成
	@param[in]	ptProfName	なにか
	@return		HRESULT		終了状態コード
*/
HRESULT SqlTreeTableCreate( LPTSTR ptProfName )
{
	//	プロフ情報
	CONST CHAR	cacProfilesTable[] = { ("CREATE TABLE Profiles ( id INTEGER PRIMARY KEY, profname TEXT NOT NULL, rootpath TEXT NULL)") };
	//	初期プロフ名作成
	CONST TCHAR	catProfInsFmt[] = { TEXT("INSERT INTO Profiles ( profname ) VALUES( '%s' )") };
	//	ツリー情報
	CONST CHAR	cacTreeNodeTable[] = { ("CREATE TABLE TreeNode ( id INTEGER PRIMARY KEY, type INTEGER NOT NULL, parentid INTEGER NOT NULL, nodename TEXT NOT NULL )") };
	//	副タブ情報
	CONST CHAR	cacMultiTabTable[] = { ("CREATE TABLE MultiTab ( id INTEGER PRIMARY KEY, filepath TEXT NOT NULL, basename TEXT NOT NULL, dispname TEXT )") };	//	20120613	表示名称追加
	//	使用AA情報
	CONST CHAR	cacArtListTable[]  = { ("CREATE TABLE ArtList ( id INTEGER PRIMARY KEY, count INTEGER NOT NULL, folder TEXT NOT NULL, lastuse  REAL NOT NULL, hash INTEGER NOT NULL, conts BLOB NOT NULL )") };

	CHAR	acBuildVer[SUB_STRING], acText[MAX_PATH];
	TCHAR	atStr[MAX_STRING];
	SYSTEMTIME	stSysTime;

	BYTE	yMode = FALSE;	//	Tableあったとかなかったとか
	INT		rslt;

	UINT	dVersion;
	CHAR	acQuery[MAX_PATH];

#ifdef _DEBUG
	INT		i;
#endif
	sqlite3_stmt	*statement;

	ZeroMemory( acText, sizeof(acText) );

	//	テーブルの存在を確認する
	rslt = sqlite3_prepare( gpDataBase, cacDetectTable, -1, &statement, NULL );
	if( SQLITE_OK != rslt ){	SQL_DEBUG( gpDataBase );	return E_ACCESSDENIED;	}

	rslt = sqlite3_step( statement );
	if( SQLITE_ROW == rslt )
	{
#ifdef _DEBUG
		for( i = 0; 10 > i; i++ )
		{
			TRACE( TEXT("[TREE] %s"), (LPCTSTR)sqlite3_column_text16( statement, 0 ) );
			rslt = sqlite3_step( statement );
			if( SQLITE_DONE == rslt ){	break;	}
		}
#endif
		rslt = sqlite3_finalize( statement );
		yMode = TRUE;
	}
	//	まず、てーぶりょが有るか無いかについて

	if( !(yMode) )
	{

		TRACE( TEXT("ツリー用テーブルが見つからなかった") );

		rslt = sqlite3_finalize( statement );	//	どっちにしても解除


	//VERSION番号テーブル作成<表には出ない
		rslt = sqlite3_prepare( gpDataBase, cacVersionTable, -1, &statement, NULL );
		if( SQLITE_OK != rslt ){	SQL_DEBUG( gpDataBase );	return E_ACCESSDENIED;	}
		rslt = sqlite3_step( statement );	//	実行
		if( SQLITE_DONE != rslt ){	SQL_DEBUG( gpDataBase );	return E_ACCESSDENIED;	}
		rslt = sqlite3_finalize(statement);

		//VERSION内容を作成	20120613変更
		GetLocalTime( &stSysTime );
		StringCchPrintfA( acBuildVer, SUB_STRING, ("%d.%02d%02d.%02d%02d.%d"), stSysTime.wYear, stSysTime.wMonth, stSysTime.wDay, stSysTime.wHour, stSysTime.wMinute, SUBTAB_NAME_VER );
		StringCchPrintfA( acText, MAX_PATH, cacVerStrInsFmt, SUBTAB_NAME_VER, acBuildVer );
		//	初期データぶち込む
		rslt = sqlite3_prepare( gpDataBase, acText, -1, &statement, NULL );
		if( SQLITE_OK != rslt ){	SQL_DEBUG( gpDataBase );	return E_ACCESSDENIED;	}
		sqlite3_reset( statement );
		rslt = sqlite3_step( statement );
		sqlite3_finalize(statement);


	//プロフテーブルを作成
		rslt = sqlite3_prepare( gpDataBase, cacProfilesTable, -1, &statement, NULL );
		if( SQLITE_OK != rslt ){	SQL_DEBUG( gpDataBase );	return E_ACCESSDENIED;	}
		rslt = sqlite3_step( statement );	//	実行
		if( SQLITE_DONE != rslt ){	SQL_DEBUG( gpDataBase );	return E_ACCESSDENIED;	}
		rslt = sqlite3_finalize(statement);

		//初期値を作成
		ZeroMemory( atStr, sizeof(atStr) );
		StringCchPrintf( atStr, MAX_STRING, catProfInsFmt, ptProfName );
		rslt = sqlite3_prepare16( gpDataBase, atStr, -1, &statement, NULL );
		if( SQLITE_OK != rslt ){	SQL_DEBUG( gpDataBase );	return E_ACCESSDENIED;	}
		sqlite3_reset( statement );
		rslt = sqlite3_step( statement );
		sqlite3_finalize(statement);

	//ツリーテーブルを生成
		rslt = sqlite3_prepare( gpDataBase, cacTreeNodeTable, -1, &statement, NULL );
//.........这里部分代码省略.........
开发者ID:SikigamiHNQ,项目名称:OrinrinEditor,代码行数:101,代码来源:MaaSqlManipulate.cpp


注:本文中的StringCchPrintf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。