?? stutil.h
字號:
/////////////////////////////////////////////////////////////////////////////
// File name: STUtil.h
// Author: Vassili Philippov (vasja@spbteam.com)
// Created: May 2001
// Last changed: 11 September 2001
// Version: 1.0
// Description: Different useful functions that are missed in Windows CE
// like creating unique GUID, handling COM exceptions,
// handling hardware keys, etc.
/////////////////////////////////////////////////////////////////////////////
// LICENSE
//
// Free for uncommercial use. Contact author to get commercial use license.
#if !defined(AFX_STUTIL_H__C403F6AF_B3FA_4BDA_A15F_7DA68EB6E3BF__INCLUDED_)
#define AFX_STUTIL_H__C403F6AF_B3FA_4BDA_A15F_7DA68EB6E3BF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef BOOL (__stdcall *UnregisterFunc1Proc)( UINT, UINT );
/////////////////////////////////////////////////////////////////////////////
// This class is a container of some useful functions
// implemented as static methods.
class CSTUtil
{
public:
// Creates unique GUID. But because this function uses
// random generator instead of computer id it cannot be
// garanted that generated GUID is unique in the world.
// Returns S_OK if GUID was successefully generated
static HRESULT CoCreateGuid(GUID *pguid);
// Starts the given executable file with the given command line
// arguments. Returns TRUE if the executable file was started successefully
// and FALSE in case of some error.
// Note: you should pass full path to the executable file.
static BOOL RunExecutable(CString strExecutableFilePath, CString strArguments = _T(""));
// Starts the given executable file with the given command line
// arguments. Returns TRUE if the executable file was started successefully
// and FALSE in case of some error. This methos waits until the start
// program will be finished.
// Note: you should pass full path to the executable file.
static BOOL RunExecutableAndWait(CString strExecutableFilePath, CString strArguments = _T(""));
// Returns full file name of the program (currently run executable file).
static CString GetProgramFilePath();
// Returns folder that contains the program file (currently run executable file).
static CString GetProgramFolder();
//Creates utils class. Loads necessary dlls.
CSTUtil();
//Unoads used dlls.
~CSTUtil();
//Redirect hardware key to the given window. Fixes bug in standard
//RegisterHotKey function (uses UnregisterFunc1 function from coredll.dll).
//See help for standard RegisterHotKey function for parameters values.
BOOL RegisterHotKey(HWND hWnd, int id, UINT vk);
private:
static DWORD m_wClockSequenceBase;
static WORD m_wDeviceId1;
static WORD m_wDeviceId2;
static WORD m_wDeviceId3;
HINSTANCE m_hCoreDll;
UnregisterFunc1Proc m_procUndergisterFunc;
};
/////////////////////////////////////////////////////////////////////////////
// The CSTComError class encapsulates the HRESULT error code.
class CSTComError
{
public:
// Default constructor creates object that encapsulates S_OK code
CSTComError();
// Default object that encapsulates the given error code
CSTComError(HRESULT hrError);
// Copy constructor.
CSTComError(const CSTComError &src);
// Assignes information about COM error
CSTComError& operator=(const CSTComError &src);
// Raw HRESULT item passed into the constructor.
HRESULT Error() const;
private:
HRESULT m_hrError;
};
// Returns information about the last COM error
CSTComError GetComError();
extern CSTComError lastComError;
/////////////////////////////////////////////////////////////////////////////
// Functions and macros for handling COM error without C++ exceptions (these
// exceptions are not implemented in eVC).
// Code of the exception that will be thrown in case of
// COM error HRESULT.
#define EXCEPTION_COMERROR 4549
// Definition of standard function that is used by smart
// pointers to report about error HRESULT code. This function
// throws exception using RaiseException function. This
// exception could be catched using
// __except (CATCH_COM_ERROR)
// code. If ST_IGNORE_COM_EXCEPTIONS is defined this function
// does nothing (no exception is thrown).
extern void __stdcall _com_issue_error(HRESULT hResult);
// Definition of standard function that is used by smart
// pointers to report about error HRESULT code. This function
// throws exception using RaiseException function. This
// exception could be catched using
// __except (CATCH_COM_ERROR)
// code. If ST_IGNORE_COM_EXCEPTIONS is defined this function
// does nothing (no exception is thrown).
extern void __stdcall _com_issue_errorex(HRESULT hResult, IUnknown* pUnknown, REFIID refid);
// Checks whether the exception corresponds to COM error or
// not and fill lastComError variable with information about
// COM error. This function should be called from __except.
// Returns true is dwCode equals
extern int ComErrorFilterFunction(DWORD dwCode, LPEXCEPTION_POINTERS info);
// This macro represents right calling of ComErrorFilterFunction
// function from __except. Just write
// __except (CATCH_COM_ERROR)
// to catch COM error exceptions.
#define CATCH_COM_ERROR ComErrorFilterFunction(GetExceptionCode(), GetExceptionInformation())
#endif // !defined(AFX_STUTIL_H__C403F6AF_B3FA_4BDA_A15F_7DA68EB6E3BF__INCLUDED_)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -