龙空技术网

生成的dll文件

青山依旧337 2980

前言:

当前大家对“mfc封装dll”大致比较注重,你们都想要了解一些“mfc封装dll”的相关内容。那么小编在网上收集了一些关于“mfc封装dll””的相关资讯,希望大家能喜欢,姐妹们快快来学习一下吧!

1一种是用到MFC的,就象楼上说的一样,建一个工程“MFC Wizard(dll)”,然后按提示走,再把你的CPP文件加到工程里就行了。

2另一种是不用到MFC,建一个“Win32 Dynamic~Link Library”工程,是一个单纯的Win32动态库,是一个空的工程,需要把你的CPP文件加入工程中,还要在你的CPP文件里加入动态库入口

CPP文件加入工程中:#include "stdafx.h"//#include "jni.h"#include "AutoClick.h"#include "windows.h"#include "math.h"#include <iostream>#include "tchar.h"#include <string>#include <iostream>#include <iomanip>//不要忘记包含此头文件using namespace std;#define _WIN32_WINNT 0x0501 BOOL APIENTRY DllMain( HANDLE hModule,                        DWORD  ul_reason_for_call,                        LPVOID lpReserved					 ){    return TRUE;}int num1;int num2;char ch1[20];RECT rect ;POINT pNow;HWND mhwnd;HWND mhwnd1;HWND mhwnd2;HWND mhwnd3;HWND mhwnd_zs;HWND hwnd;HWND hwndPointNow1 = NULL;HWND hwndPointNowB1 = NULL;HWND hwndPointNowB = NULL;HWND hwndPointNowS1 = NULL;HWND hwndPointNowS = NULL;HWND hwndPointNowC1 = NULL;HWND hwndPointNowC = NULL;HWND hwndPointNowD1 = NULL;HWND hwndPointNowD = NULL;HWND hwndPointNowZXG1 = NULL;HWND hwndPointNowZXG = NULL;HWND hwndPointNowGO1 = NULL;HWND hwndPointNowGO = NULL;const char *pwd =NULL;int  cx   =  GetSystemMetrics( SM_CXFULLSCREEN );int  cy   =  GetSystemMetrics( SM_CYFULLSCREEN );JNIEXPORT void JNICALL Java_AutoClick_Click(JNIEnv *env, jobject loader, jstring  type, jstring  name){    int YN=1;    HWND mhwnd;// FindWindow("TdxW_MainFrame_Class",NULL);//MHPToolBar扫雷//招商证券智远理财服务平台V2.39 - [行情图-沪深A股	const char *stype = env->GetStringUTFChars(type, 0); 	const char *localStr;    int length = (env)->GetStringLength(name);    const jchar* jcstr = (env)->GetStringChars(name, 0 );	    char* rtn = (char*)malloc( length*2+1 );    int size = 0;    	size = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)jcstr, length, rtn,(length*2+1), NULL, NULL );    if( size <= 0 ){}        //return NULL;    (env)->ReleaseStringChars(name, jcstr );    rtn[size] = 0;    localStr=rtn;    //cout<<localStr<<endl;  //显示          //free(localStr);  //这个不能要    printf(localStr);//显示		mhwnd = FindWindow(NULL,localStr);	printf("%x\n",mhwnd);	if(mhwnd){		              SetForegroundWindow(mhwnd);			  //7确认处理超出范围			  Sleep(100);			  mhwnd1 = FindWindowEx(mhwnd,NULL,"Button","执行方案");			  printf("%x\n",mhwnd1);			  			  if(mhwnd1)			  { 					PostMessage(mhwnd1,BM_CLICK,NULL,NULL);								  }	          	          Sleep(1000);	}}

标签: #mfc封装dll