• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 74, 文章 - 0, 評(píng)論 - 26, 引用 - 0
            數(shù)據(jù)加載中……

            用戶空間和設(shè)備驅(qū)動(dòng)程序通信


            CreateFile
            ReadFile WriteFile DeviceIoControl (將會(huì)產(chǎn)生 IRP 包)
            Closehandle

            posted @ 2007-11-20 09:35 井泉 閱讀(130) | 評(píng)論 (0)編輯 收藏

            c++ 和 jscript

            #pragma once

            #include <afxdisp.h>
            #include <activscp.h>

            class CCodeObject;
            class CScriptSite;

            class CScriptingSupportHelper
            {
            public:
                CScriptingSupportHelper();
                ~CScriptingSupportHelper();

                BOOL Create(CWnd* pWnd);
                BOOL RunScript(CString str);

                CCodeObject* GetCodeObject() const { return m_pCodeObject; }
                CScriptSite* GetScriptSite() const { return m_pScriptSite; }
                IActiveScript* GetActiveScript() const { return m_pActiveScript; }

            private:
                CCodeObject* m_pCodeObject;
                CScriptSite* m_pScriptSite;

                IActiveScript* m_pActiveScript;  
                IActiveScriptParse* m_pActiveScriptParse;
            };

            class CCodeObject : public CCmdTarget
            {
            public:
                CCodeObject(CScriptingSupportHelper* pScripting, CWnd* pWnd);
                virtual ~CCodeObject();

                void Line(long, long, long, long);
                void Ellipse(long, long, long, long);
                void DrawText(LPCTSTR msg, long x, long y, long w, long h);

                void OnPaint();
                void OnMouseClick(long x, long y);

            private:
                CWnd* m_pWnd;
                CScriptingSupportHelper* m_pScripting;
                BOOL GetDispatch(OLECHAR* name, COleDispatchDriver& disp, DISPID& dispid);

                enum
                {
                    idLine = 1,
                    idEllipse,
                    idDrawText,
                };

                DECLARE_DISPATCH_MAP()
            };

            class CScriptSite : public IActiveScriptSite
            {
            public:
                CScriptSite(CScriptingSupportHelper* pScripting)  
                {
                    m_pScripting = pScripting;
                };
               
                ~CScriptSite() 
                {
                };

                virtual ULONG STDMETHODCALLTYPE AddRef()
                {   
                    return InterlockedIncrement(&m_nRefCount);
                }
               
                virtual ULONG STDMETHODCALLTYPE Release()
                {    
                    return InterlockedDecrement(&m_nRefCount);
                };
               
                virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** ppObj)
                {
                    *ppObj = NULL;

                    if ((iid == IID_IUnknown) || (iid == IID_IActiveScriptSite))
                    {
                        *ppObj= (IActiveScriptSite*)this;
                        AddRef();
                        return S_OK;
                    }

                    return E_NOINTERFACE;
                }

                virtual HRESULT STDMETHODCALLTYPE GetLCID(LCID __RPC_FAR *)
                {
                    return E_NOTIMPL;
                }
               
                virtual HRESULT STDMETHODCALLTYPE GetItemInfo(LPCOLESTR, DWORD, IUnknown __RPC_FAR *__RPC_FAR * pObj, ITypeInfo __RPC_FAR *__RPC_FAR *)
                {
                    ASSERT(m_pScripting);
                    ASSERT(m_pScripting->GetCodeObject());

                    *pObj = m_pScripting->GetCodeObject()->GetIDispatch(TRUE);
                    return S_OK;
                }
                   
                virtual HRESULT STDMETHODCALLTYPE GetDocVersionString(BSTR __RPC_FAR *)
                {
                    return E_NOTIMPL;
                }
                   
                virtual HRESULT STDMETHODCALLTYPE OnScriptTerminate(const VARIANT __RPC_FAR * ,const EXCEPINFO __RPC_FAR *)
                {
                    return E_NOTIMPL;
                }

                   
                virtual HRESULT STDMETHODCALLTYPE OnStateChange(SCRIPTSTATE)
                {
                    return E_NOTIMPL;
                }
                   
                virtual HRESULT STDMETHODCALLTYPE OnScriptError(IActiveScriptError __RPC_FAR * pScriptError)
                {
                    return E_NOTIMPL;
                }
                   
                virtual HRESULT STDMETHODCALLTYPE OnEnterScript()
                {
                    return E_NOTIMPL;
                }
                   
                virtual HRESULT STDMETHODCALLTYPE OnLeaveScript()
                {
                    return E_NOTIMPL;
                }

            private:
                long m_nRefCount;
                CScriptingSupportHelper* m_pScripting;
            };

            #include "StdAfx.h"
            #include "ScriptingSupport.h"

            CCodeObject::CCodeObject(CScriptingSupportHelper* pScripting, CWnd* pWnd)
                : m_pWnd(pWnd),
                  m_pScripting(pScripting)

            {
                EnableAutomation();
            }

            CCodeObject::~CCodeObject()
            {
            }

            BEGIN_DISPATCH_MAP(CCodeObject, CCmdTarget)
            DISP_FUNCTION_ID(CCodeObject, "Line", idLine, Line, VT_EMPTY, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
            DISP_FUNCTION_ID(CCodeObject, "Ellipse", idEllipse, Ellipse, VT_EMPTY, VTS_I4 VTS_I4 VTS_I4 VTS_I4)
            DISP_FUNCTION_ID(CCodeObject, "DrawText", idDrawText, DrawText, VT_EMPTY, VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4)
            END_DISPATCH_MAP()

            void CCodeObject::Line(long x1, long y1, long x2, long y2)
            {
                CWindowDC dc(m_pWnd);

                dc.MoveTo(x1, y1);
                dc.LineTo(x2, y2);
            }

            void CCodeObject::Ellipse(long x1, long y1, long x2, long y2)
            {
                CWindowDC dc(m_pWnd);
                dc.Ellipse(x1, y1, x2, y2);
            }

            void CCodeObject::DrawText(LPCTSTR msg, long x, long y, long w, long h)
            {
                CWindowDC dc(m_pWnd);
                CRect rect(x, y, x+w, y+h);

                dc.DrawText(msg, rect, 0);
            }

            void CCodeObject::OnPaint()
            {
                COleDispatchDriver disp;
                DISPID dispid;
                if (GetDispatch(L"OnPaint", disp, dispid)) {
                    disp.InvokeHelper(dispid, DISPATCH_METHOD, VT_EMPTY, 0, 0);
                }
            }

            BOOL CCodeObject::GetDispatch(OLECHAR* name, COleDispatchDriver& disp, DISPID& dispid)
            {
                IDispatch* pScriptDispatch = 0;
                m_pScripting->GetActiveScript()->GetScriptDispatch(0, &pScriptDispatch);
                disp.AttachDispatch(pScriptDispatch);
                HRESULT hr = pScriptDispatch->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
                return SUCCEEDED(hr);
            }

            void CCodeObject::OnMouseClick(long x, long y)
            {
                COleDispatchDriver disp;
                DISPID dispid;
                if (GetDispatch(L"OnMouseClick", disp, dispid)) {
                    disp.InvokeHelper(dispid, DISPATCH_METHOD, VT_EMPTY, 0, (const BYTE*)(VTS_I4 VTS_I4), x, y);
                }
            }

            CScriptingSupportHelper::CScriptingSupportHelper()
                : m_pCodeObject(0),
                  m_pScriptSite(0),
                  m_pActiveScript(0),
                  m_pActiveScriptParse(0)
            {
            }

            CScriptingSupportHelper::~CScriptingSupportHelper()
            {
                if (m_pActiveScript)
                {
                    m_pActiveScript->Close();
                    m_pActiveScriptParse->Release();
                    m_pActiveScript->Release();
                }

                delete m_pCodeObject; m_pCodeObject=0;
                delete m_pScriptSite; m_pScriptSite=0;
            }

            BOOL CScriptingSupportHelper::RunScript(CString strText)
            {
                EXCEPINFO ei = {0};
                BSTR bstrText = strText.AllocSysString();
                m_pActiveScriptParse->ParseScriptText(bstrText, NULL, NULL, NULL, 0, 0, 0, NULL, &ei);
                SysFreeString(bstrText);

                m_pActiveScript->SetScriptState(SCRIPTSTATE_CONNECTED);

                return TRUE;
            }

            BOOL CScriptingSupportHelper::Create(CWnd* pWnd)
            {
                m_pCodeObject = new CCodeObject(this, pWnd);
                m_pScriptSite = new CScriptSite(this);

                CLSID clsidJScript;
                CLSIDFromProgID(L"JScript", &clsidJScript);
                CoCreateInstance(clsidJScript, NULL, CLSCTX_INPROC_SERVER, IID_IActiveScript, (void **)&m_pActiveScript);
                m_pActiveScript->QueryInterface(IID_IActiveScriptParse, (void**)&m_pActiveScriptParse);
                m_pActiveScript->SetScriptSite(m_pScriptSite);
                m_pActiveScript->AddNamedItem(L"Code", SCRIPTITEM_ISVISIBLE | SCRIPTITEM_ISSOURCE | SCRIPTITEM_GLOBALMEMBERS);
                m_pActiveScriptParse->InitNew();


                return TRUE;
            }




            posted @ 2007-11-20 09:19 井泉 閱讀(659) | 評(píng)論 (0)編輯 收藏

            (msdn)Using MFC to Automate SAPI (SAPI 5.3)http://msdn2.microsoft.com/en-us/library/ms717069.aspx

            Microsoft Speech API 5.3   用oleview 可以產(chǎn)生 idl 文件 再用 midl工具 可以產(chǎn)生 tlb,h,c 存根文件 等.

            Using MFC to Automate SAPI

            Introduction

            The Microsoft Foundation Classes (MFC) provides an easy and convenient way to automate calls to SAPI using its Class Wizard to generate wrappers for the SAPI layer from the SAPI Type Library.

            In order to accomplish this, perform the following steps:

            1. Create a new MFCAppWizard(exe) project in Visual C++.
            2. Based on the type of application you are creating, follow the wizard prompts. In Step 3 of the wizard prompts, (or Step 2 if you are creating a Dialog Based application) make sure that the Automation check box is selected under the heading, What other support would you like to include?

            Once the new project is ready, access Class Wizard.

            1. Click the Automation tab, and then click Add Class and select From a type library in the drop-down list.
            2. Browse for the sapi.dll file and open it.
            3. Select the classes you would like Class Wizard to generate a wrapper for. The resulting default header and implementation files are sapi.h and sapi.cpp respectively. The rest of this document assumes that you have chosen to use these default file names. Click OK.
            4. You should now be back in the Class Wizard window. Click OK.
            After you are done with the above steps, Visual C++ will automatically add the Class Wizard generated files sapi.cpp and sapi.h to your project.

            Upon viewing the sapi.h file, you should notice that it is nothing more than an automation wrapper that has been generated for all the classes you selected. Notice that all the classes inherit from COleDispatchDriver, hence the dispatch interface needs to be set up. This only requires a few lines of simple code, after which the wrapper class can be used just like any other C++ class.

            Example

            This example assumes that you chose to generate a wrapper for the ISpeechVoice class from among any other classes you may have selected. Using the project created above, include the sapi.h file within a source file in the project that will make automation calls to SAPI using the wrapper. In that source file, type the following code.

            CLSID CLSID_SpVoice;    // class ID for the SAPI SpVoice object
            LPDISPATCH pDisp; // dispatch interface for the class
            ISpeechVoice voice; // use the MFC Class Wizard generated wrapper

            CLSIDFromProgID(L"SAPI.SpVoice", &CLSID;_SpVoice);
            voice.CreateDispatch(CLSID_SpVoice);
            pDisp = voice.m_lpDispatch;

            HRESULT hr = pDisp->QueryInterface(CLSID_SpVoice, (void**)&voice;.m_lpDispatch);

            if (hr == S_OK) {
            pDisp->Release();
            }
            else {
            voice.AttachDispatch(pDisp, TRUE);
            }

            voice.Speak("hello world", 1); // asynchronous call to Speak method of ISpeechVoice interface

            If you have been following the steps outlined above properly, you should hear your computer say "hello world!" That's all there is to using MFC to make automation calls to SAPI. Currently however, not all the wrapper classes generated by MFC's Class Wizard work properly. For instance, the ISpeechLexicon interface does not work. The work around for this is to implement your own automation wrapper classes using C++. The steps to do that are beyond the scope of this document. Of course, you can always use the COM interfaces in C++ and Automation in Visual Basic to ensure that every interface in SAPI works easily and flawlessly.

            posted @ 2007-11-20 09:06 井泉 閱讀(1186) | 評(píng)論 (1)編輯 收藏

            客戶端調(diào)用com

            void opercom()
            {
                ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
                //    {2D8EBDEE-437C-47c9-ABCC-F169E5E781D0}speeddial
                //    {85140985-7A18-4009-B5FB-43268FD154F8}ISpRecognizerLite
                 
                    CLSID CLSID_SpVoice;
                    ::CLSIDFromProgID(L"SpeedDial", &CLSID_SpVoice);
                    LPCLASSFACTORY pClsF;
                    LPUNKNOWN punk;                   ::CoGetClassObject(CLSID_SpVoice,CLSCTX_INPROC_SERVER,NULL,IID_IClassFactory,(void**)&pClsF);
                    pClsF->CreateInstance(NULL,IID_IUnknown,(void**)&punk);
                punk->QueryInterface(IID_ISpRecognizerLite,(void**)&非抽象類);
                ::CoUninitialize();
            }

            posted @ 2007-11-20 08:49 井泉 閱讀(293) | 評(píng)論 (0)編輯 收藏

            (轉(zhuǎn))手工注冊(cè)com

            BOOL regcom(LPCWSTR strLib)
            {
                //for registration
                HMODULE hLib = ::LoadLibrary(strLib);
                if(hLib == 0) {
                    return FALSE;
                }
                HRESULT (STDAPICALLTYPE *pDllRegisterServer)();
                (FARPROC&)pDllRegisterServer = ::GetProcAddress(hLib, _T("DllRegisterServer"));
                if(pDllRegisterServer == NULL) {  
                    ::FreeLibrary(hLib);
                    return FALSE;
                }
                if(FAILED(pDllRegisterServer ())) {
                    ::FreeLibrary(hLib);
                    return FALSE;
                } else {
                    ::FreeLibrary(hLib);
                    return TRUE;
                }
            }

            BOOL unregcom(LPCWSTR strLib)
            {
                HMODULE hLib = ::LoadLibrary(strLib);
                if(hLib == 0) {
                    return FALSE;
                }
                HRESULT (STDAPICALLTYPE *pDllUnregisterServer)();
                (FARPROC&)pDllUnregisterServer = ::GetProcAddress(hLib, _T("DllUnregisterServer"));
                if(pDllUnregisterServer == NULL) {
                    ::FreeLibrary(hLib);
                    return FALSE;
                }
                if(FAILED(pDllUnregisterServer())) {
                    ::FreeLibrary(hLib);
                    return FALSE;
                } else {
                    ::FreeLibrary(hLib);
                    return TRUE;
                }
            }


            posted @ 2007-11-20 08:48 井泉 閱讀(205) | 評(píng)論 (0)編輯 收藏

            (轉(zhuǎn))Rapi 使用

            void CopyFilePCtoWinCE(CString strFileNamePC, CString strFileNamePPC)
            {
                CFile oldFile;
                oldFile.Open(strFileNamePC, CFile::modeRead |CFile::typeBinary);
                int iLen = oldFile.GetLength();
                iLen = iLen / BUFFER_SIZE;
                BSTR bstr = strFileNamePPC.AllocSysString();
                SysFreeString(bstr);
                CeRapiInit();
                HANDLE h = CeCreateFile(bstr, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                    OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
                char cTemp[BUFFER_SIZE];
                DWORD nbytes;
                int iTotBytes = 0;
                int iReaded=0;
                while((iReaded=oldFile.Read(&cTemp, BUFFER_SIZE)) >= 1)
                    CeWriteFile(h, &cTemp, (DWORD)iReaded, &nbytes, NULL);
                CeCloseHandle(h);
                oldFile.Close();
                CeRapiUninit();
            }

            void CopyFileWinCEtoPC(CString strFileNamePPC, CString strFileNamePC)
            {
                BSTR bstr = strFileNamePPC.AllocSysString();
                SysFreeString(bstr);
                CeRapiInit();

                HANDLE h;
                h = CeCreateFile(bstr, GENERIC_READ, FILE_SHARE_READ, NULL,
                    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

                CFile oldFile;
                oldFile.Open(strFileNamePC, CFile::modeCreate | CFile::modeWrite);

                char cTemp[BUFFER_SIZE];
                DWORD nbytes;
                CString s;

                while(CeReadFile(h, &cTemp, (DWORD)BUFFER_SIZE, &nbytes, NULL) == TRUE)
                {
                    oldFile.Write(&cTemp, nbytes);
                    if(nbytes < BUFFER_SIZE)
                        break;
                }
                CeCloseHandle(h);
                oldFile.Close();
                CeRapiUninit(); 
            }

            BOOL DeleteFileFromCE(CString strFileNamePPC)
            {
                BSTR bstr = strFileNamePPC.AllocSysString();
                SysFreeString(bstr);
                CeRapiInit();
                BOOL bRet = CeDeleteFile(bstr);
                CeRapiUninit();
                return bRet;
            }


            posted @ 2007-11-20 08:46 井泉 閱讀(1276) | 評(píng)論 (0)編輯 收藏

            判斷是否有非英文字符

            bool HaveNOASCII(LPWSTR str)
            {
             char nstring[100]={0};
             wcstombs( nstring,str,100);
             return (strlen(nstring)==wcslen(str));
             
            }

            posted @ 2007-11-19 16:07 井泉 閱讀(944) | 評(píng)論 (1)編輯 收藏

            函數(shù)對(duì)比


            用_t
            替換字符'w',比如 wcsncpy  to _tcsncpy(自適應(yīng)函數(shù)).

            _tcsncpy_l 后綴  _l 不推薦使用的函數(shù)

            _tcsncpy_s 后綴  _s Security Enhancements in the CRT

            _tcsncpy_s_l 后綴  _s_l 同 _s

            security enhancements


            寬字符處理函數(shù)函數(shù)與普通函數(shù)對(duì)照表 
              
             

            字符分類:     寬字符函數(shù)普通C函數(shù)描述 
            iswalnum()     isalnum() 測(cè)試字符是否為數(shù)字或字母 
            iswalpha()     isalpha() 測(cè)試字符是否是字母 
            iswcntrl()     iscntrl() 測(cè)試字符是否是控制符 
            iswdigit()     isdigit() 測(cè)試字符是否為數(shù)字 
            iswgraph()     isgraph() 測(cè)試字符是否是可見字符 
            iswlower()     islower() 測(cè)試字符是否是小寫字符 
            iswprint()     isprint() 測(cè)試字符是否是可打印字符 
            iswpunct()     ispunct() 測(cè)試字符是否是標(biāo)點(diǎn)符號(hào) 
            iswspace()     isspace() 測(cè)試字符是否是空白符號(hào) 
            iswupper()     isupper() 測(cè)試字符是否是大寫字符 
            iswxdigit()     isxdigit()測(cè)試字符是否是十六進(jìn)制的數(shù)字 


            大小寫轉(zhuǎn)換:     
            寬字符函數(shù)    普通C函數(shù)描述 
            towlower()     tolower() 把字符轉(zhuǎn)換為小寫 
            towupper()     toupper() 把字符轉(zhuǎn)換為大寫 


            字符比較:     寬字符函數(shù)普通C函數(shù)描述 
            wcscoll()     strcoll() 比較字符串 


            日期和時(shí)間轉(zhuǎn)換: 
            寬字符函數(shù)描述 
            strftime()     根據(jù)指定的字符串格式和locale設(shè)置格式化日期和時(shí)間 
            wcsftime()     根據(jù)指定的字符串格式和locale設(shè)置格式化日期和時(shí)間, 并返回寬字符串 
            strptime()     根據(jù)指定格式把字符串轉(zhuǎn)換為時(shí)間值, 是strftime的反過程 


            打印和掃描字符串: 
            寬字符函數(shù)描述 
            fprintf()
            /fwprintf()     使用vararg參量的格式化輸出 
            fscanf()
            /fwscanf()         格式化讀入 
            printf()             使用vararg參量的格式化輸出到標(biāo)準(zhǔn)輸出 
            scanf()             從標(biāo)準(zhǔn)輸入的格式化讀入 
            sprintf()
            /swprintf()     根據(jù)vararg參量表格式化成字符串 
            sscanf()             以字符串作格式化讀入 
            vfprintf()
            /vfwprintf()     使用stdarg參量表格式化輸出到文件 
            vprintf()             使用stdarg參量表格式化輸出到標(biāo)準(zhǔn)輸出 
            vsprintf()
            /vswprintf()     格式化stdarg參量表并寫到字符串 


            數(shù)字轉(zhuǎn)換: 
            寬字符函數(shù)    普通C函數(shù)描述 
            wcstod()     strtod()  把寬字符的初始部分轉(zhuǎn)換為雙精度浮點(diǎn)數(shù) 
            wcstol()     strtol()  把寬字符的初始部分轉(zhuǎn)換為長(zhǎng)整數(shù) 
            wcstoul()     strtoul() 把寬字符的初始部分轉(zhuǎn)換為無符號(hào)長(zhǎng)整數(shù) 


            多字節(jié)字符和寬字符轉(zhuǎn)換及操作: 
            寬字符函數(shù)描述 
            mblen()         根據(jù)locale的設(shè)置確定字符的字節(jié)數(shù) 
            mbstowcs()         把多字節(jié)字符串轉(zhuǎn)換為寬字符串 
            mbtowc()
            /btowc()    把多字節(jié)字符轉(zhuǎn)換為寬字符 
            wcstombs()         把寬字符串轉(zhuǎn)換為多字節(jié)字符串 
            wctomb()
            /wctob()     把寬字符轉(zhuǎn)換為多字節(jié)字符 


            輸入和輸出: 
            寬字符函數(shù)    普通C函數(shù)描述 
            fgetwc()     fgetc()     從流中讀入一個(gè)字符并轉(zhuǎn)換為寬字符 
            fgetws()     fgets()     從流中讀入一個(gè)字符串并轉(zhuǎn)換為寬字符串 
            fputwc()     fputc()     把寬字符轉(zhuǎn)換為多字節(jié)字符并且輸出到標(biāo)準(zhǔn)輸出 
            fputws()     fputs()     把寬字符串轉(zhuǎn)換為多字節(jié)字符并且輸出到標(biāo)準(zhǔn)輸出串 
            getwc()     getc()     從標(biāo)準(zhǔn)輸入中讀取字符, 并且轉(zhuǎn)換為寬字符 
            getwchar()     getchar()     從標(biāo)準(zhǔn)輸入中讀取字符, 并且轉(zhuǎn)換為寬字符 
            None         gets()     使用fgetws() 
            putwc()     putc()     把寬字符轉(zhuǎn)換成多字節(jié)字符并且寫到標(biāo)準(zhǔn)輸出 
            putwchar()     putchar()     把寬字符轉(zhuǎn)換成多字節(jié)字符并且寫到標(biāo)準(zhǔn)輸出 
            None         puts()     使用fputws() 
            ungetwc()     ungetc()     把一個(gè)寬字符放回到輸入流中 


            字符串操作: 
            寬字符函數(shù)        普通C函數(shù)描述 
            wcscat()         strcat()     把一個(gè)字符串接到另一個(gè)字符串的尾部 
            wcsncat()         strncat()     類似于wcscat(), 而且指定粘接字符串的粘接長(zhǎng)度. 
            wcschr()         strchr()     查找子字符串的第一個(gè)位置 
            wcsrchr()         strrchr()     從尾部開始查找子字符串出現(xiàn)的第一個(gè)位置 
            wcspbrk()         strpbrk()     從一字符字符串中查找另一字符串中任何一個(gè)字符第一次出現(xiàn)的位置 
            wcswcs()
            /wcsstr()     strchr()     在一字符串中查找另一字符串第一次出現(xiàn)的位置 
            wcscspn()         strcspn()     返回不包含第二個(gè)字符串的的初始數(shù)目 
            wcsspn()         strspn()     返回包含第二個(gè)字符串的初始數(shù)目 
            wcscpy()         strcpy()     拷貝字符串 
            wcsncpy()         strncpy()     類似于wcscpy(), 同時(shí)指定拷貝的數(shù)目 
            wcscmp()         strcmp()     比較兩個(gè)寬字符串 
            wcsncmp()         strncmp()     類似于wcscmp(), 還要指定比較字符字符串的數(shù)目 
            wcslen()         strlen()     獲得寬字符串的數(shù)目 
            wcstok()         strtok()     根據(jù)標(biāo)示符把寬字符串分解成一系列字符串 
            wcswidth()         None         獲得寬字符串的寬度 
            wcwidth()         None         獲得寬字符的寬度 


            另外還有對(duì)應(yīng)于memory操作的 wmemcpy(), wmemchr(), wmemcmp(), wmemmove(), wmemset().

            posted @ 2007-11-19 10:25 井泉 閱讀(1387) | 評(píng)論 (0)編輯 收藏

            IBasicVideo::GetCurrentImage 抓圖

            http://www.geekpage.jp/en/programming/directshow/getcurrentimage.php

            #include <stdio.h>
            #include <dshow.h>
            // change here
            #define	FILENAME L"C:\\DXSDK\\Samples\\Media\\butterfly.mpg"
            // note that this sample fails on some environment
            int
            main()
            {
            IGraphBuilder *pGraphBuilder;
            IMediaControl *pMediaControl;
            IBasicVideo *pBasicVideo;
            CoInitialize(NULL);
            CoCreateInstance(CLSID_FilterGraph,
            NULL,
            CLSCTX_INPROC,
            IID_IGraphBuilder,
            (LPVOID *)&pGraphBuilder);
            pGraphBuilder->QueryInterface(IID_IMediaControl,
            (LPVOID *)&pMediaControl);
            pMediaControl->RenderFile(FILENAME);
            
            pGraphBuilder->QueryInterface(IID_IBasicVideo,
            (LPVOID *)&pBasicVideo);
            
            pMediaControl->Run();
            // The image will be saved when OK is clicked
            MessageBox(NULL,
            "Grab Image",
            "Grab",
            MB_OK);
            
            // Must Pause before using GetCurrentImage
            pMediaControl->Pause();
            // get width and height
            long height, width;
            pBasicVideo->get_VideoHeight(&height);
            pBasicVideo->get_VideoWidth(&width);
            long bufSize;
            long *imgData;
            HRESULT hr;
            /*
            The second value is NULL to resolve required buffer size.
            The required buffer size will be returned in variable "bufSize".
            */
            hr = pBasicVideo->GetCurrentImage(&bufSize, NULL);
            if (FAILED(hr)) {
            printf("GetCurrentImage failed\n");
            return 1;
            }
            if (bufSize < 1) {
            printf("failed to get data size\n");
            return 1;
            }
            imgData = (long *)malloc(bufSize);
            // The data will be in DIB format
            pBasicVideo->GetCurrentImage(&bufSize, imgData);
            
            // save DIB file as Bitmap.
            // This sample saves image as bitmap to help
            // understanding the sample.
            HANDLE fh;
            BITMAPFILEHEADER bmphdr;
            BITMAPINFOHEADER bmpinfo;
            DWORD nWritten;
            memset(&bmphdr, 0, sizeof(bmphdr));
            memset(&bmpinfo, 0, sizeof(bmpinfo));
            bmphdr.bfType = ('M' << 8) | 'B';
            bmphdr.bfSize = sizeof(bmphdr) + sizeof(bmpinfo) + bufSize;
            bmphdr.bfOffBits = sizeof(bmphdr) + sizeof(bmpinfo);
            bmpinfo.biSize = sizeof(bmpinfo);
            bmpinfo.biWidth = width;
            bmpinfo.biHeight = height;
            bmpinfo.biPlanes = 1;
            bmpinfo.biBitCount = 32;
            fh = CreateFile("result.bmp",
            GENERIC_WRITE, 0, NULL,
            CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
            WriteFile(fh, &bmphdr, sizeof(bmphdr), &nWritten, NULL);
            WriteFile(fh, &bmpinfo, sizeof(bmpinfo), &nWritten, NULL);
            WriteFile(fh, imgData, bufSize, &nWritten, NULL);
            CloseHandle(fh);
            
            free(imgData);
            // Release resource
            pBasicVideo->Release();
            
            pMediaControl->Release();
            pGraphBuilder->Release();
            CoUninitialize();
            return 0;
            }

            posted @ 2007-11-19 08:40 井泉 閱讀(3563) | 評(píng)論 (0)編輯 收藏

            wince 物理地址訪問二

            You can use functions that are exposed by the WDbgExts_CE.h header file in debugger extension commands. When developing a debugger extension, these functions can be helpful in controlling and examining the target device being debugged.

            The following table shows debugger extension functions.

            Programming element Description

            CheckControlC

            This function checks to see whether the user pressed the CTRL+C key combination.

            Disassm

            This function disassembles an instruction and stores in a buffer a string that can be printed.

            dprintf

            This function prints a formatted string to the command window for the debugger.

            EXTSTACKTRACE

            This structure specifies stack frames for the StackTrace function.

            GetContext

            This function obtains the context of the process being debugged.

            GetDebuggerData

            This function retrieves information stored in a data block.

            GetExpression

            This function returns the value of an expression.

            GetSetSympath

            This function obtains or sets the search path for symbols.

            GetSymbol

            This function locates the symbol nearest to a specified address.

            Ioctl

            This function is an entry point for much of the functionality provided by the extension functions for the kernel debugger.

            ReadControlSpace

            This function reads a CPU-specific control space into an array.

            ReadMemory

            This function reads memory from the process being debugged.

            The entire area of memory must be accessible, or the operation fails.

            ReadPhysical

            This function reads from physical memory.

            SetContext

            This function sets the context of the process being debugged.

            SetThreadForOperation

            This function specifies a thread to use for the next call to the StackTrace function

            StackTrace

            This function receives a stack trace for the process being debugged.

            WriteIoSpace

            This function writes to system I/O locations.

            WriteMemory

            This function writes memory to a process being debugged.

            The entire area of memory must be accessible, or the operation fails.

            WritePhysical

            This function writes to physical memory.

            posted @ 2007-11-15 12:47 井泉 閱讀(318) | 評(píng)論 (1)編輯 收藏

            僅列出標(biāo)題
            共8頁: 1 2 3 4 5 6 7 8 
            精品国产91久久久久久久| 久久久久久噜噜精品免费直播| 欧美熟妇另类久久久久久不卡| 久久久久亚洲av无码专区| 久久97久久97精品免视看秋霞| 一本一本久久aa综合精品| 国产亚洲成人久久| 久久久久久九九99精品| 污污内射久久一区二区欧美日韩 | 久久国产成人午夜AV影院| 久久99国产精品久久99小说| 久久96国产精品久久久| 欧美日韩精品久久久久| 91久久精品国产91性色也| 中文无码久久精品| 亚洲国产成人久久综合一区77| 久久99国产亚洲高清观看首页| 亚洲香蕉网久久综合影视 | 国产香蕉久久精品综合网| 97精品伊人久久久大香线蕉| 看久久久久久a级毛片| 久久亚洲sm情趣捆绑调教| 久久久久亚洲AV无码专区桃色| 久久精品人人做人人爽电影| 亚洲av伊人久久综合密臀性色| 色综合久久久久综合99| 亚洲一区中文字幕久久| 精品国产福利久久久| 精品久久久久久亚洲精品| 无码AV中文字幕久久专区| 久久综合亚洲鲁鲁五月天| 97精品伊人久久大香线蕉| 久久夜色精品国产www| 欧美性猛交xxxx免费看久久久| 久久精品国产一区二区三区不卡| 品成人欧美大片久久国产欧美| 久久精品视频免费| 99久久免费国产精品| 久久99精品久久久久久水蜜桃| 精品久久久久中文字| 久久久久久噜噜精品免费直播|