分享

生成的dll文件

 山峰云绕 2022-03-22

https://www.toutiao.com/article/7077157129458795046/?log_from=bc736d2808c24_1647919860827

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

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

生成的dll文件
生成的dll文件
生成的dll文件
生成的dll文件
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);

	}
}
生成的dll文件

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多