xyxfly的专栏

每个人都有潜在的能量,只是很容易:被习惯所掩盖,被时间所迷离,被惰性所消磨。

xyxflyID:xyxfly
2704次访问,排名2万外好友0人,关注者6
xyxfly的文章
原创 7 篇
翻译 0 篇
转载 1 篇
评论 24 篇
xyxfly的公告
月 [下月] [上月]
QQ:39940649
最近评论
443:如果是sql2005 从excel里面读数据会提示要将某个设置打开,有没有方法?
443:bu cuo
文章分类
收藏
    相册
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 IUnknown接口收藏

    新一篇: 汇编学习 | 旧一篇: 客户端弹出窗口

    creditverification.dll

    // CreditVerification.h
    #pragma once

    #ifdef _DLL
    #define DLLSPEC __declspec (dllexport)
    #else
    #define DLLSPEC __declspec (dllimport)
    #endif

    #define interface struct

    interface IUnknown
    {
           virtual long QueryInterface(IID& iid, void** pp) = 0;
           virtual long AddRef() = 0;
           virtual long Release() = 0;
    };

    interface ICreditVerification : IUnknown
    {
     virtual void SetCardType(char* s) = 0;
     virtual bool VerifyCardNumber(long n) = 0;
    };

    DLLSPEC ICreditVerification* GetCreditVerificationObject();

     

    // creditverification.cpp : Defines the entry point for the DLL application.
    //

    #include "stdafx.h"

    #define _DLL
    #include "creditverification.h"

    BOOL APIENTRY DllMain( HANDLE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
          )
    {
        return TRUE;
    }

    class CCreditVerification : public ICreditVerification
    {
    private:
     enum CardType {Visa, MasterCard, Amex} m_type;
     long m_refCount;
    public:
     CCreditVerification() : m_refCount(0) {}
     long QueryInterface(IID& iid, void** pp) { return 0; }

     long AddRef() { return ++m_refCount; }
     long Release()
     {
      if (--m_refCount == 0)
      {
       delete this;
       return 0;
      }
      return m_refCount;
     }

     void SetCardType(char* s)
     {
      if (0 == strcmp("Visa", s))
       m_type = Visa;
      else if (0 == strcmp("MasterCard", s))
       m_type = MasterCard;
      else m_type = Amex;
     }
     bool VerifyCardNumber(long n)
     {
      if (m_type == Visa)
       return (n % 2);
      else if (m_type == MasterCard)
       return (n % 3);
      else if (m_type == Amex)
       return (n % 5);
      else return false;
     }
    };

    DLLSPEC ICreditVerification* GetCreditVerificationObject()
    {
     ICreditVerification* p = new CCreditVerification;
     p->AddRef();
     return p;
    }

    建DLL时选空project的话:

    f:\vs.netprojects\creditverification\creditverification.h(14): error C2061: syntax error : identifier 'IID'
    f:\vs.netprojects\creditverification\creditverification.cpp(56): error C2259: 'CCreditVerification' : cannot instantiate abstract class
    原因未知。

    另#define WIN32_LEAN_AND_MEAN作用?
     

    发表于 @ 2006年07月25日 22:37:00|评论(loading...)|编辑

    新一篇: 汇编学习 | 旧一篇: 客户端弹出窗口

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © xyxfly