中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

詳解MFC/C++調用易語言的整數型和文本型與VS2010互動

發布時間:2020-09-06 22:57:55 來源:腳本之家 閱讀:323 作者:laozhang 欄目:編程語言

1、LoadDll.cpp

#include "StdAfx.h"
#include "LoadDLL.h"

pMFCdll_OneVOID_OneVOID    MFCdll_OneVOID_OneVOID;
pMFCdll_OneWORD_OneVOID    MFCdll_OneWORD_OneVOID;
pMFCdll_OneCHAR_OneVOID    MFCdll_OneCHAR_OneVOID;


pMFCdll_OneWORD_OneWORD    MFCdll_OneWORD_OneWORD;
pMFCdll_OneWORD_TwoWORD    MFCdll_OneWORD_TwoWORD;
pMFCdll_OneWORD_ThreeWORD  MFCdll_OneWORD_ThreeWORD;
pMFCdll_OneWORD_FourWORD  MFCdll_OneWORD_FourWORD;
pMFCdll_OneWORD_FiveWORD  MFCdll_OneWORD_FiveWORD;
pMFCdll_OneWORD_SixWORD    MFCdll_OneWORD_SixWORD;


pMFCdll_OneWORD_OneChar    MFCdll_OneWORD_OneChar;
pMFCdll_OneWORD_TwoChar    MFCdll_OneWORD_TwoChar;
pMFCdll_OneWORD_ThreeChar  MFCdll_OneWORD_ThreeChar;
pMFCdll_OneWORD_FourChar  MFCdll_OneWORD_FourChar;
pMFCdll_OneWORD_FiveChar  MFCdll_OneWORD_FiveChar;
pMFCdll_OneWORD_SixChar    MFCdll_OneWORD_SixChar;


pMFCdll_OneChar_OneChar    MFCdll_OneChar_OneChar;
pMFCdll_OneChar_TwoChar    MFCdll_OneChar_TwoChar;
pMFCdll_OneChar_ThreeChar  MFCdll_OneChar_ThreeChar;
pMFCdll_OneChar_FourChar  MFCdll_OneChar_FourChar;
pMFCdll_OneChar_FiveChar  MFCdll_OneChar_FiveChar;
pMFCdll_OneChar_SixChar    MFCdll_OneChar_SixChar;


pMFCdll_OneChar_OneWORD    MFCdll_OneChar_OneWORD;
pMFCdll_OneChar_TwoWORD    MFCdll_OneChar_TwoWORD;
pMFCdll_OneChar_ThreeWORD  MFCdll_OneChar_ThreeWORD;
pMFCdll_OneChar_FourWORD  MFCdll_OneChar_FourWORD;
pMFCdll_OneChar_FiveWORD  MFCdll_OneChar_FiveWORD;
pMFCdll_OneChar_SixWORD    MFCdll_OneChar_SixWORD;


HINSTANCE  g_Hinstance;  //實例句柄


//加載DLL
BOOL LoadDll(char *name)
{
  
  if(g_Hinstance != NULL) return TRUE;  //如果g_Hinstance不為空就返回

  MFCdll_OneWORD_SixWORD = NULL;  //這里是加載ZJY_SoftOverTime用的
  MFCdll_OneCHAR_OneVOID = NULL;  //這里是加載ZJY_GetSystemDisk用的

  g_Hinstance = LoadLibrary(name);
  if(g_Hinstance == NULL)
  {
//    AfxMessageBox("加載dll動態庫失敗!");
    return FALSE;
  }

  MFCdll_OneWORD_SixWORD = (pMFCdll_OneWORD_SixWORD)GetProcAddress(g_Hinstance, "ZJY_SoftOverTime");
  MFCdll_OneCHAR_OneVOID = (pMFCdll_OneCHAR_OneVOID)GetProcAddress(g_Hinstance, "ZJY_GetSystemDisk");
  if(NULL == MFCdll_OneWORD_SixWORD || NULL == MFCdll_OneCHAR_OneVOID)
  {
//    AfxMessageBox("加載動態庫MFCCallBackDllTest函數失敗");
    FreeLibrary(g_Hinstance);
    g_Hinstance = NULL;
    return FALSE;
  }
  return TRUE;
}

//卸載DLL
void UninstallDll()
{
  if (g_Hinstance != NULL)
  {
    MFCdll_OneWORD_SixWORD = NULL;
    MFCdll_OneCHAR_OneVOID = NULL;
    FreeLibrary(g_Hinstance);
    g_Hinstance = NULL;
  }
}

2、LoadDll.h

#ifndef __MFCCLOADDLL_H
#define __MFCCLOADDLL_H

#include <windows.h>

BOOL LoadDll(char *name);  //加載DLL
void UninstallDll();    //卸載DLL

/************************************************************************/
/*易語言:沒參數帶返回值的,不帶的。
/***********************************************************************/
typedef void  (WINAPI *pMFCdll_OneVOID_OneVOID)  ();  //返回VOID
typedef WORD  (WINAPI *pMFCdll_OneWORD_OneVOID)  ();  //返回WORD
typedef char * (WINAPI *pMFCdll_OneCHAR_OneVOID)  ();  //返回CHAR

/************************************************************************/
/*易語言:整數型接口  <返回值,整數型>(整數型 a, 整數型 b,整數型 c,整數型 d,整數型 e,整數型 f)*/
/***********************************************************************/
typedef WORD (WINAPI *pMFCdll_OneWORD_OneWORD)  (WORD a);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_TwoWORD)  (WORD a , WORD b);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_ThreeWORD)(WORD a , WORD b ,WORD c);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_FourWORD)  (WORD a , WORD b ,WORD c ,WORD d);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_FiveWORD)  (WORD a , WORD b ,WORD c ,WORD d ,WORD e);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_SixWORD)  (WORD a , WORD b ,WORD c ,WORD d ,WORD e,WORD f);  //返回WORD

typedef WORD (WINAPI *pMFCdll_OneWORD_OneChar)  (char * a);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_TwoChar)  (char * a , char * b);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_ThreeChar)(char * a , char * b ,char * c);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_FourChar)  (char * a , char * b ,char * c ,char * d);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_FiveChar)  (char * a , char * b ,char * c ,char * d ,char * e);  //返回WORD
typedef WORD (WINAPI *pMFCdll_OneWORD_SixChar)  (char * a , char * b ,char * c ,char * d ,char * e,char * f);  //返回WORD

/************************************************************************/
/*易語言:字符串接口  <返回值,CString>(文本型 a, 整數型 b,整數型 c,整數型 d,整數型 e,整數型 f)*/
/***********************************************************************/
typedef char * (WINAPI *pMFCdll_OneChar_OneChar)  (char *);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_TwoChar)  (char * , char *);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_ThreeChar)  (char * , char * ,char *);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_FourChar)  (char * , char * ,char * ,char *);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_FiveChar)  (char * , char * ,char * ,char * ,char *);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_SixChar)  (char * , char * ,char * ,char * ,char * ,char *);  //返回cahr *

typedef char * (WINAPI *pMFCdll_OneChar_OneWORD)  (WORD a);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_TwoWORD)  (WORD a , WORD b);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_ThreeWORD)  (WORD a , WORD b ,WORD c);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_FourWORD)  (WORD a , WORD b ,WORD c ,WORD d);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_FiveWORD)  (WORD a , WORD b ,WORD c ,WORD d ,WORD e);  //返回cahr *
typedef char * (WINAPI *pMFCdll_OneChar_SixWORD)  (WORD a , WORD b ,WORD c ,WORD d ,WORD e,WORD f);  //返回cahr *

/************************************************************************/
/*易語言使用外部定義
/***********************************************************************/
extern pMFCdll_OneVOID_OneVOID    MFCdll_OneVOID_OneVOID;
extern pMFCdll_OneWORD_OneVOID    MFCdll_OneWORD_OneVOID;
extern pMFCdll_OneCHAR_OneVOID    MFCdll_OneCHAR_OneVOID;


extern pMFCdll_OneWORD_OneWORD    MFCdll_OneWORD_OneWORD;
extern pMFCdll_OneWORD_TwoWORD    MFCdll_OneWORD_TwoWORD;
extern pMFCdll_OneWORD_ThreeWORD  MFCdll_OneWORD_ThreeWORD;
extern pMFCdll_OneWORD_FourWORD    MFCdll_OneWORD_FourWORD;
extern pMFCdll_OneWORD_FiveWORD    MFCdll_OneWORD_FiveWORD;
extern pMFCdll_OneWORD_SixWORD    MFCdll_OneWORD_SixWORD;


extern pMFCdll_OneWORD_OneChar    MFCdll_OneWORD_OneChar;
extern pMFCdll_OneWORD_TwoChar    MFCdll_OneWORD_TwoChar;
extern pMFCdll_OneWORD_ThreeChar  MFCdll_OneWORD_ThreeChar;
extern pMFCdll_OneWORD_FourChar    MFCdll_OneWORD_FourChar;
extern pMFCdll_OneWORD_FiveChar    MFCdll_OneWORD_FiveChar;
extern pMFCdll_OneWORD_SixChar    MFCdll_OneWORD_SixChar;


extern pMFCdll_OneChar_OneChar    MFCdll_OneChar_OneChar;
extern pMFCdll_OneChar_TwoChar    MFCdll_OneChar_TwoChar;
extern pMFCdll_OneChar_ThreeChar  MFCdll_OneChar_ThreeChar;
extern pMFCdll_OneChar_FourChar    MFCdll_OneChar_FourChar;
extern pMFCdll_OneChar_FiveChar    MFCdll_OneChar_FiveChar;
extern pMFCdll_OneChar_SixChar    MFCdll_OneChar_SixChar;


extern pMFCdll_OneChar_OneWORD    MFCdll_OneChar_OneWORD;
extern pMFCdll_OneChar_TwoWORD    MFCdll_OneChar_TwoWORD;
extern pMFCdll_OneChar_ThreeWORD  MFCdll_OneChar_ThreeWORD;
extern pMFCdll_OneChar_FourWORD    MFCdll_OneChar_FourWORD;
extern pMFCdll_OneChar_FiveWORD    MFCdll_OneChar_FiveWORD;
extern pMFCdll_OneChar_SixWORD    MFCdll_OneChar_SixWORD;


#endif    //MFCCLOADDLL_H

3、這里為不帶Dlg的那個項目文件

// testDll.cpp : 定義應用程序的類行為。
//

#include "stdafx.h"
#include "testDll.h"
#include "testDllDlg.h"

#include "LoadDLL.h"

//*************原來的代碼不動******************

BOOL CtestDllApp::InitInstance()
{  
    //這里上面不動,下面加載DLL,就是游戲讀條一樣的,現在只有一個
  if(LoadDll("C://Users//Administrator//Desktop//ZJDLLV1.0.3.dll") == FALSE)
  {

    AfxMessageBox("ZJDLLV1.0.3.dll,加載失敗!");
    AfxGetMainWnd()->CloseWindow();    
  }
  else
  {
    AfxMessageBox("ZJDLLV1.0.3.dll,加載成功!");
  }
    //下面系統的
  CtestDllDlg dlg;
  m_pMainWnd = &dlg;
  INT_PTR nResponse = dlg.DoModal();
  if (nResponse == IDOK)
  {
    // TODO: 在此放置處理何時用
    // “確定”來關閉對話框的代碼
  }
  else if (nResponse == IDCANCEL)
  {
    // TODO: 在此放置處理何時用
    // “取消”來關閉對話框的代碼
  }

  // 刪除上面創建的 shell 管理器。
  if (pShellManager != NULL)
  {
    delete pShellManager;
  }

  // 由于對話框已關閉,所以將返回 FALSE 以便退出應用程序,
  // 而不是啟動應用程序的消息泵。
  return FALSE;
}

4、這里帶Dlg的那個項目文件

#include "LoadDLL.h"
//-------中間的不動---------
//這里是按鈕單機自動生成的槽函數
void CtestDllDlg::OnBnClickedOk()
{ 
  WORD reslut = MFCdll_OneWORD_SixWORD(2017,9,7,15,23,0);

  if(reslut == 1)
  {
    AfxMessageBox("軟件可正常使用!");
  }
  else if(reslut == 0)
  {
    AfxMessageBox("軟件已過期!");
  }

  AfxMessageBox(MFCdll_OneCHAR_OneVOID());
}

5、教程結束。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

湖北省| 舞钢市| 扶风县| 即墨市| 井陉县| 宜春市| 宁国市| 云安县| 和平县| 昆山市| 宿迁市| 胶州市| 兰坪| 浮梁县| 谢通门县| 淮南市| 霍邱县| 宾阳县| 南川市| 玛沁县| 巴林左旗| 巩义市| 眉山市| 曲靖市| 武安市| 德清县| 静安区| 洛南县| 尼木县| 揭阳市| 法库县| 阿坝| 梅州市| 如东县| 青龙| 林周县| 彰武县| 浦北县| 松桃| 内乡县| 昌图县|