随笔 - 74, 文章 - 0, 评论 - 26, 引用 - 0
数据加载中……

用户空间和设备驱动程序通信


CreateFile
ReadFile WriteFile DeviceIoControl (将会产生 IRP 包)
Closehandle

posted @ 2007-11-20 09:35 井泉 阅读(125) | 评论 (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 井泉 阅读(646) | 评论 (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 井泉 阅读(1127) | 评论 (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 井泉 阅读(284) | 评论 (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 井泉 阅读(191) | 评论 (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 井泉 阅读(1258) | 评论 (0)编辑 收藏

判断是否有非英文字符

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

posted @ 2007-11-19 16:07 井泉 阅读(913) | 评论 (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 井泉 阅读(1373) | 评论 (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 井泉 阅读(3525) | 评论 (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 井泉 阅读(312) | 评论 (1)编辑 收藏

仅列出标题
共8页: 1 2 3 4 5 6 7 8