MSDN 中去找!  sample 中有的是!

解决方案 »

  1.   

    怎么才能生成一个空的dll工程,
    VC向导生成的那些是干什么的?
      

  2.   

    我有:// AddressMap.h : main header file for the ADDRESSMAP DLL
    //#if !defined(AFX_ADDRESSMAP_H__463AB76E_B91B_4CD7_81D7_38EF2B9F6E60__INCLUDED_)
    #define AFX_ADDRESSMAP_H__463AB76E_B91B_4CD7_81D7_38EF2B9F6E60__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#ifndef __AFXWIN_H__
    #error include 'stdafx.h' before including this file for PCH
    #endif#include "resource.h" // main symbols/////////////////////////////////////////////////////////////////////////////
    // CAddressMapApp
    // See AddressMap.cpp for the implementation of this class
    //class CAddressMapApp : public CWinApp
    {
    public:
    CAddressMapApp();// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAddressMapApp)
    //}}AFX_VIRTUAL //{{AFX_MSG(CAddressMapApp)
    // NOTE - the ClassWizard will add and remove member functions here.
    //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
    ///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_ADDRESSMAP_H__463AB76E_B91B_4CD7_81D7_38EF2B9F6E60__INCLUDED_)
    // AddressMap.cpp : Defines the initialization routines for the DLL.
    //#include "stdafx.h"
    #include "AddressMap.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif//
    // Note!
    //
    // If this DLL is dynamically linked against the MFC
    // DLLs, any functions exported from this DLL which
    // call into MFC must have the AFX_MANAGE_STATE macro
    // added at the very beginning of the function.
    //
    // For example:
    //
    // extern "C" BOOL PASCAL EXPORT ExportedFunction()
    // {
    // AFX_MANAGE_STATE(AfxGetStaticModuleState());
    // // normal function body here
    // }
    //
    // It is very important that this macro appear in each
    // function, prior to any calls into MFC.  This means that
    // it must appear as the first statement within the 
    // function, even before any object variable declarations
    // as their constructors may generate calls into the MFC
    // DLL.
    //
    // Please see MFC Technical Notes 33 and 58 for additional
    // details.
    ///////////////////////////////////////////////////////////////////////////////
    // CAddressMapAppBEGIN_MESSAGE_MAP(CAddressMapApp, CWinApp)
    //{{AFX_MSG_MAP(CAddressMapApp)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CAddressMapApp constructionCAddressMapApp::CAddressMapApp()
    {
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
    }/////////////////////////////////////////////////////////////////////////////
    // The one and only CAddressMapApp objectCAddressMapApp theApp;BOOL __stdcall CreateMap( void * pData, long size )
    {
    HANDLE hMapping;
    BYTE * lpData; hMapping = CreateFileMapping( ( HANDLE ) 0xFFFFFFFF, NULL, PAGE_READWRITE, 
    0, size, "MYSHARE" );

    if ( hMapping == NULL )
    return FALSE; lpData = ( BYTE * )MapViewOfFile( hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0 );

    if ( lpData == NULL )
    return FALSE; memcpy( lpData, pData, size ); UnmapViewOfFile( lpData ); return TRUE;}BOOL __stdcall ReadMap( BYTE * lpData, int size )
    {
    HANDLE hMapping;
    BYTE * pData;

    hMapping = CreateFileMapping( ( HANDLE ) 0xFFFFFFFF, NULL, PAGE_READWRITE, 
    0, size, "MYSHARE" );

    if ( hMapping == NULL )
    return FALSE; pData = ( BYTE * )MapViewOfFile( hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0 );

    if ( lpData == NULL )
    return FALSE; memcpy( lpData, pData, size ); UnmapViewOfFile( pData ); return TRUE;
    }
    /////////////////////////////
    ; AddressMap.def : Declares the module parameters for the DLL.LIBRARY      "AddressMap"
    DESCRIPTION  'AddressMap Windows Dynamic Link Library'EXPORTS
        ; Explicit exports can go here
    CreateMap @1
    ReadMap @2