wolf9228 Posted February 2, 2009 Posted February 2, 2009 (edited) C++ 6 MFC Extensino DLL (using shared MFC DLL) AUTOIT_MFC_DLL.cpp ADD ON cpp FILE #ifdef AUTOIT_MFC_DLL_EXPORTS AUTOIT_MFC_DLL ===> DLL LIBRARY appname _EXPORTS AUTOIT_MFC_DLL_EXPORTS #define AUTOIT_MFC_DLL_API __declspec(dllexport) AUTOIT_MFC_DLL ===> DLL LIBRARY appname _API __declspec(dllexport) AUTOIT_MFC_DLL_API __declspec(dllexport) #define AUTOIT_MFC_DLL_API __declspec(dllimport) AUTOIT_MFC_DLL ===> DLL LIBRARY appname _API __declspec(dllimport) AUTOIT_MFC_DLL_API __declspec(dllimport) AUTOIT_MFC_DLL.dll expandcollapse popup#include "stdafx.h" #include <afxdllx.h> #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #ifdef AUTOIT_MFC_DLL_EXPORTS #define AUTOIT_MFC_DLL_API __declspec(dllexport) #else #define AUTOIT_MFC_DLL_API __declspec(dllimport) #endif extern "C" { AUTOIT_MFC_DLL_API int AfxMsBox(LPCTSTR); AUTOIT_MFC_DLL_API int CString_Find(int,LPSTR ,LPSTR); AUTOIT_MFC_DLL_API LPSTR CString_Insert(int,LPSTR,LPSTR); AUTOIT_MFC_DLL_API int CString_Get_Length(LPSTR); AUTOIT_MFC_DLL_API LPSTR CString_Replace(LPSTR,LPCTSTR,LPCTSTR); }; static AFX_EXTENSION_MODULE AUTOIT_MFC_DLLDLL = { NULL, NULL }; extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { // Remove this if you use lpReserved UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH) { TRACE0("AUTOIT_MFC_DLL.DLL Initializing!\n"); // Extension DLL one-time initialization if (!AfxInitExtensionModule(AUTOIT_MFC_DLLDLL, hInstance)) return 0; // Insert this DLL into the resource chain // NOTE: If this Extension DLL is being implicitly linked to by // an MFC Regular DLL (such as an ActiveX Control) // instead of an MFC application, then you will want to // remove this line from DllMain and put it in a separate // function exported from this Extension DLL. The Regular DLL // that uses this Extension DLL should then explicitly call that // function to initialize this Extension DLL. Otherwise, // the CDynLinkLibrary object will not be attached to the // Regular DLL's resource chain, and serious problems will // result. new CDynLinkLibrary(AUTOIT_MFC_DLLDLL); } else if (dwReason == DLL_PROCESS_DETACH) { TRACE0("AUTOIT_MFC_DLL.DLL Terminating!\n"); // Terminate the library before destructors are called AfxTermExtensionModule(AUTOIT_MFC_DLLDLL); } return 1; // ok } int AfxMsBox(LPCTSTR TXT1) { if (AfxMessageBox(TXT1)) {return 1;} return 0; } int CString_Find(int nStart ,LPSTR FSTR ,LPSTR FSUBSTR) { return CString(FSTR).Find(FSUBSTR,nStart); } LPSTR CString_Insert(int nIndex ,LPSTR ISTR ,LPSTR ISUBSTR) { CString ISTR2 = ISTR; ISTR2.Insert(nIndex,ISUBSTR); return (LPSTR) ISTR2.GetBuffer(ISTR2.GetLength()); } int CString_Get_Length(LPSTR GLSTR) { return CString(GLSTR).GetLength(); } LPSTR CString_Replace(LPSTR RSTR, LPCTSTR ipszOld , LPCTSTR ipszNew) { CString RSTR2 = RSTR; RSTR2.Replace(ipszOld,ipszNew); return (LPSTR) RSTR2.GetBuffer(RSTR2.GetLength()); } Call AUTOIT_MFC_DLL.dll (Autoit Code) expandcollapse popup$DllOpen = DllOpen(@ScriptDir & "\AUTOIT_MFC_DLL.dll") AfxMsBox("Hello World") MsgBox(0,"CString_Insert",CString_Insert(6 ,"AUTOIT" , "_MFC_DLL")) MsgBox(0,"CString_Find",CString_Find(0 ,"Hello World" ,"World")) MsgBox(0,"CString_Get_Length",CString_Get_Length("Hello World")) MsgBox(0,"CString_Replace",CString_Replace("Hello World", "World" , "Test")) Func AfxMsBox($TXT = "") $DllCall = DllCall($DllOpen,"int:cdecl","AfxMsBox","str",$TXT) Return $DllCall[0] EndFunc Func CString_Find($nStart = 0 ,$FSTR = "" ,$FSUBSTR = "") $DllCall = DllCall($DllOpen,"int:cdecl","CString_Find","int",$nStart,"str",$FSTR,"str",$FSUBSTR) Return $DllCall[0] EndFunc Func CString_Insert($nIndex = 0 ,$STR = "" ,$SUBSTR = "") $DllCall = DllCall($DllOpen,"str:cdecl","CString_Insert","int",$nIndex ,"str",$STR ,"str",$SUBSTR) Return $DllCall[0] EndFunc Func CString_Get_Length($GLSTR = "") $DllCall = DllCall($DllOpen,"int:cdecl","CString_Get_Length","str",$GLSTR) Return $DllCall[0] EndFunc Func CString_Replace($RSTR = "" , $ipszOld = "" , $ipszNew = "" ) $DllCall = DllCall($DllOpen,"str:cdecl","CString_Replace","str",$RSTR,"str",$ipszOld ,"str", $ipszNew) Return $DllCall[0] EndFunc DllClose($DllOpen) Edited April 29, 2010 by wolf9228 صرح السماء كان هنا
UEZ Posted February 2, 2009 Posted February 2, 2009 Hhhmmmm, what is this exactly? I've no C/C++ knowledge. Can you explain what you did? THANK, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
wolf9228 Posted February 4, 2009 Author Posted February 4, 2009 Hhhmmmm, what is this exactly? I've no C/C++ knowledge.Can you explain what you did?THANK,UEZ WELCOMEhttp://msdn.microsoft.com/en-us/library/ms384296(VS.71).aspxhttp://msdn.microsoft.com/en-us/library/ms384325(VS.71).aspxhttp://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.htmlhttp://support.microsoft.com/kb/123870http://support.microsoft.com/kb/98577 صرح السماء كان هنا
UEZ Posted February 4, 2009 Posted February 4, 2009 (edited) WELCOMEhttp://msdn.microsoft.com/en-us/library/ms384296(VS.71).aspxhttp://msdn.microsoft.com/en-us/library/ms384325(VS.71).aspxhttp://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.htmlhttp://support.microsoft.com/kb/123870http://support.microsoft.com/kb/98577Thanks,it's like reading Chinese or Arab UEZ Edited February 4, 2009 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now