#1
|
|||
|
|||
Create Dll C++ in VS 2015 compatible with Inno Setup
Hi! I would like to know if you can help create a post that explains in detail how to create a C ++ Dll Compatible with Inno Setup, since for some time I have not been able to do it in a stable way, to achieve this come here to see if they can help me. my problem is always the same, the Dll does not run on a PC in which it has not been compiled ... I do not explain how this happens but I invite you to look at this code. and tell me if it contains errors or something. Name of DLL is IsFunc.dll for now it only contains a single function exported .. because it is not necessary to show all the source code if the error is always given ... with any number of internal functions or exporteds. Header.h Code:
#pragma once #include <Windows.h> DllMain.cpp Code:
#include "Header.h" HWND AppHandle = 0; BOOL __stdcall EnumProc(HWND hWnd, LPARAM lParam) { DWORD Pid; WCHAR cl[14]; GetWindowThreadProcessId(hWnd, &Pid); GetClassNameW(hWnd, cl, 13); if (Pid == GetCurrentProcessId()) if (wcsstr(cl, L"TApplication")) AppHandle = hWnd; return TRUE; }; void Dll_Start(void) { EnumWindows(EnumProc, 0); }; void Dll_Stop(void) {}; BOOL __stdcall DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: Dll_Start(); break; case DLL_PROCESS_DETACH: Dll_Stop(); break; }; return TRUE; }; IsFunc.cpp Code:
#include "Header.h" extern HWND AppHandle; HWND __stdcall GetAppHandle(void) { return AppHandle; }; Defin.def Code:
LIBRARY "IsFunc" EXPORTS GetAppHandle The purpose of the GetAppHandle function is to get the Application.Handle which can not be obtained in version 5.5.9 of Inno Setup. I know that you can get this value without any Dll but it is indispensable that the Dll conosca the value of the Application.Handle so that the other functions that I will show you can work ... Personally I do not like working with Inno Setup version 5.5.1 Advance .. I prefer version 5.5.9 for the new features .. Inno Setup Script Code:
[Setup] AppId={{684EB0C0-995E-4B93-916E-01B0AFA5EA45} AppName=Test AppVersion=1.5 ;AppVerName=Test AppPublisher=Test AppPublisherURL=http://www.example.com/ AppSupportURL=http://www.example.com/ AppUpdatesURL=http://www.example.com/ CreateAppDir=no OutputDir=.\ OutputBaseFilename=test Compression=lzma SolidCompression=yes [Languages] Name: "default"; MessagesFile: "compiler:Default.isl" [Files] Source: "IsFunc.dll"; Flags: dontcopy; Code:
function GetAppHandle(): Longint; external 'GetAppHandle@files:IsFunc.dll stdcall'; function InitializeSetup(): Boolean; begin MsgBox(IntToStr(GetAppHandle()), mbInformation, MB_OK); end; During compilation there are no errors or anything .. It works perfectly in the image you see the value obtained by the function GetAppHandle And here is the problem ..
but if I try on another PC this happens Apparently it's as if the linked function does not exist.?? And after performing debugging tests with VS I realized that the Dll is loaded into memory and the code of the DllMain function is executed but it just does not connect to the other functions Despite my lack of experience in creating Dlls .. I have programming skills in the C ++, Delphi, Inno Setup, Java, PHP, HTML, and others languages and never had a problem of this type I think maybe I'm missing some property in the VS solution or maybe I'm creating it in the wrong way, to work on Inno Setup Thank you in advance for any help Last edited by MCI; 05-09-2017 at 17:36. Reason: Fix's |
The Following 5 Users Say Thank You to MCI For This Useful Post: | ||
78372 (06-09-2017), arkantos7 (06-09-2017), felice2011 (06-09-2017), Razor12911 (05-09-2017), Siber Pro (29-05-2018) |
Sponsored Links |
#2
|
||||
|
||||
wow seems interesting I follow with pleasure, but unfortunately this is not a programming forum, let's see who goes on..
__________________
≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ « I Mediocri Imitano, I Geni Copiano, Dio Crea & Distrugge » (Io Ridefinisco & Perfeziono le Loro Opere Rendendole Uniche) ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ « Mediocrities Imitate, Genius Copy, God Creates & Destroys » (I Reconsider & Improve Their Works, Rending Them One And Only) Last edited by felice2011; 06-09-2017 at 00:42. |
#3
|
|||
|
|||
Code:
#include <windows.h> HANDLE __stdcall MyHandle(void) { return GetCurrentProcess(); } Code:
EXPORTS MyHandle |
#4
|
|||
|
|||
Thank you
Friend this function does not return the desired value .. But thanks .. the problem in is the why the dll does not work on another pc, and it is still trying and I think it is that it has some dependence but they do not understand why .. :confuso: :confuso:
|
#5
|
||||
|
||||
It does not work on another PC because the *.dll created/written, must be saved in the executable to be rewritten/read in other PC systems. Or at least I guess this is your problem..
__________________
≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ « I Mediocri Imitano, I Geni Copiano, Dio Crea & Distrugge » (Io Ridefinisco & Perfeziono le Loro Opere Rendendole Uniche) ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ « Mediocrities Imitate, Genius Copy, God Creates & Destroys » (I Reconsider & Improve Their Works, Rending Them One And Only) |
#6
|
|||
|
|||
The problem is that the DLL does not run .... on another PC ... It only works on the PC on which it was written / created
|
#7
|
|||
|
|||
I'm going to upload the complete source code to see if that makes it easier to solve the problem.
|
#8
|
||||
|
||||
Check that the code creates the same path on another PC and reads and decodes the DLL in the existing path
__________________
≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ « I Mediocri Imitano, I Geni Copiano, Dio Crea & Distrugge » (Io Ridefinisco & Perfeziono le Loro Opere Rendendole Uniche) ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ « Mediocrities Imitate, Genius Copy, God Creates & Destroys » (I Reconsider & Improve Their Works, Rending Them One And Only) |
#9
|
|||
|
|||
In effect this happens since the DLL is included in a test with Inno Setup , and when transferring the creator file by Inno Setup, the displayed error occurs. at the time of running it on another PC.
|
#10
|
||||
|
||||
Code:
HANDLE __stdcall MyHandle(void) { return AppHandler; } Code:
extern "C" __declspec(dllexport) HANDLE MyHandle(void) { return AppHandler; } Code:
//MyDll.cpp #pragma once typedef long int HWND; extern "C" __declspec(dllexport) HWND Func(void) { return 30*5; //150 }
__________________
"There are three things that sages fear... The tormented sea, a moonless night and the wrath of a gentleness man." - The fear of the Sages. Last edited by kassane; 06-09-2017 at 12:09. Reason: My example |
#11
|
|||
|
|||
Quote:
|
#12
|
||||
|
||||
Weird! Well, it worked normally here. Did you test my simple example?
-------------------------------------------------------------------- Update: -- c++ src updated english strings example -- Obj. Pascal (freepascal and Delphi) src added -- setup src and demo Note: (demo) C++ DLL require vcredist 2017! Install vcredist 2017: Code:
https://go.microsoft.com/fwlink/?LinkId=746571
__________________
"There are three things that sages fear... The tormented sea, a moonless night and the wrath of a gentleness man." - The fear of the Sages. Last edited by kassane; 03-12-2017 at 05:25. Reason: vcredist2017 x86 |
The Following User Says Thank You to kassane For This Useful Post: | ||
Simorq (08-09-2017) |
#13
|
|||
|
|||
Thank you..
Quote:
anyway, thank you. I'm going to upload a file so that you can test it all that you want, and I'd appreciate it if you inform me the result .. |
The Following User Says Thank You to MCI For This Useful Post: | ||
kassane (06-09-2017) |
#14
|
||||
|
||||
Update example!
__________________
"There are three things that sages fear... The tormented sea, a moonless night and the wrath of a gentleness man." - The fear of the Sages. |
#15
|
|||
|
|||
Not Work.
Try it on another pc so you can see that it does not work.
|
Tags |
dll |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
BlackBox v2 | y_thelastknight | Conversion Tutorials | 566 | 13-10-2023 18:04 |
INNO TROUBLESHOOT - Tutorials and Answers about INNO Setup | REV0 | Conversion Tutorials | 129 | 21-05-2021 06:51 |
Inno Setup: Additional Libraries | altef_4 | Conversion Tutorials | 50 | 21-10-2020 10:59 |
Useful Dll for Inno Setup users | peterf1999 | Conversion Tutorials | 88 | 01-12-2017 17:00 |
INNO TUTORIAL - Using Unicode and ANSI Versions of INNO Setup | REV0 | Conversion Tutorials | 51 | 26-03-2015 07:57 |