• <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, 評論 - 26, 引用 - 0
            數據加載中……

            用戶空間和設備驅動程序通信


            CreateFile
            ReadFile WriteFile DeviceIoControl (將會產生 IRP 包)
            Closehandle

            posted @ 2007-11-20 09:35 井泉 閱讀(134) | 評論 (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 井泉 閱讀(665) | 評論 (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 可以產生 idl 文件 再用 midl工具 可以產生 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 井泉 閱讀(1191) | 評論 (1)編輯 收藏

            客戶端調用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 井泉 閱讀(298) | 評論 (0)編輯 收藏

            (轉)手工注冊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 井泉 閱讀(211) | 評論 (0)編輯 收藏

            (轉)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 井泉 閱讀(1278) | 評論 (0)編輯 收藏

            判斷是否有非英文字符

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

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

            函數對比


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

            _tcsncpy_l 后綴  _l 不推薦使用的函數

            _tcsncpy_s 后綴  _s Security Enhancements in the CRT

            _tcsncpy_s_l 后綴  _s_l 同 _s

            security enhancements


            寬字符處理函數函數與普通函數對照表 
              
             

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


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


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


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


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


            數字轉換: 
            寬字符函數    普通C函數描述 
            wcstod()     strtod()  把寬字符的初始部分轉換為雙精度浮點數 
            wcstol()     strtol()  把寬字符的初始部分轉換為長整數 
            wcstoul()     strtoul() 把寬字符的初始部分轉換為無符號長整數 


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


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


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


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

            posted @ 2007-11-19 10:25 井泉 閱讀(1392) | 評論 (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 井泉 閱讀(3574) | 評論 (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 井泉 閱讀(319) | 評論 (1)編輯 收藏

            僅列出標題
            共8頁: 1 2 3 4 5 6 7 8 
            国内精品久久国产大陆| 亚洲国产成人精品女人久久久 | 久久久久久午夜成人影院| 狠狠色婷婷久久综合频道日韩| 久久人爽人人爽人人片AV| 欧美777精品久久久久网| 精品久久国产一区二区三区香蕉| 亚洲日韩欧美一区久久久久我| 国产激情久久久久久熟女老人| 久久91精品国产91久久小草| 日韩久久久久中文字幕人妻 | 久久影院午夜理论片无码| 久久亚洲日韩精品一区二区三区| 亚洲国产成人久久综合碰碰动漫3d | 久久天天躁狠狠躁夜夜网站| 99久久99久久精品国产片| 欧美亚洲国产精品久久高清| 日本道色综合久久影院| 亚洲精品无码久久久久sm| 久久久久久噜噜精品免费直播| 久久青青草原亚洲av无码app| 狠狠综合久久综合中文88| 久久超碰97人人做人人爱| 久久午夜夜伦鲁鲁片免费无码影视 | 欧美伊香蕉久久综合类网站| 久久久久久综合网天天| 久久综合狠狠综合久久97色| 久久久久99精品成人片直播| 超级碰碰碰碰97久久久久| 亚洲国产精品久久66| 91精品国产综合久久精品| 亚洲综合伊人久久综合| 久久无码AV一区二区三区| 久久精品无码一区二区app| 久久免费高清视频| 99久久国产亚洲高清观看2024 | 伊人久久大香线蕉亚洲| 一本久久免费视频| 久久综合久久美利坚合众国| 日产久久强奸免费的看| 久久综合一区二区无码|