Go Back   FileForums > Game Backup > PC Games > PC Games - CD/DVD Conversions > Conversion Tutorials

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2017, 16:09
MCI MCI is offline
Registered User
 
Join Date: Sep 2017
Location: Venezuela
Posts: 9
Thanks: 0
Thanked 6 Times in 2 Posts
MCI is on a distinguished road
Cool 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;
[CENTER]That's all the source Code ..




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 16:36. Reason: Fix's
Reply With Quote
The Following 5 Users Say Thank You to MCI For This Useful Post:
78372 (06-09-2017), arkantos7 (06-09-2017), felice2011 (05-09-2017), Razor12911 (05-09-2017), Siber Pro (29-05-2018)
Sponsored Links
  #2  
Old 05-09-2017, 23:39
felice2011's Avatar
felice2011 felice2011 is offline
Registered User
 
Join Date: Feb 2011
Location: italy
Posts: 836
Thanks: 354
Thanked 1,152 Times in 388 Posts
felice2011 is on a distinguished road
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; 05-09-2017 at 23:42.
Reply With Quote
  #3  
Old 06-09-2017, 01:41
ravencrow ravencrow is offline
Registered User
 
Join Date: Feb 2015
Location: SG
Posts: 19
Thanks: 29
Thanked 12 Times in 8 Posts
ravencrow is on a distinguished road
Code:
#include <windows.h>

HANDLE __stdcall MyHandle(void)
{
  return GetCurrentProcess();
}
Code:
EXPORTS
  MyHandle
Reply With Quote
  #4  
Old 06-09-2017, 05:19
MCI MCI is offline
Registered User
 
Join Date: Sep 2017
Location: Venezuela
Posts: 9
Thanks: 0
Thanked 6 Times in 2 Posts
MCI is on a distinguished road
Cool Thank you

Quote:
Originally Posted by ravencrow View Post
Code:
#include <windows.h>

HANDLE __stdcall MyHandle(void)
{
  return GetCurrentProcess();
}
Code:
EXPORTS
  MyHandle
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:
Reply With Quote
  #5  
Old 06-09-2017, 07:30
felice2011's Avatar
felice2011 felice2011 is offline
Registered User
 
Join Date: Feb 2011
Location: italy
Posts: 836
Thanks: 354
Thanked 1,152 Times in 388 Posts
felice2011 is on a distinguished road
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)
Reply With Quote
  #6  
Old 06-09-2017, 08:43
MCI MCI is offline
Registered User
 
Join Date: Sep 2017
Location: Venezuela
Posts: 9
Thanks: 0
Thanked 6 Times in 2 Posts
MCI is on a distinguished road
Cool

Quote:
Originally Posted by felice2011 View Post
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..
The problem is that the DLL does not run .... on another PC ... It only works on the PC on which it was written / created
Reply With Quote
  #7  
Old 06-09-2017, 08:45
MCI MCI is offline
Registered User
 
Join Date: Sep 2017
Location: Venezuela
Posts: 9
Thanks: 0
Thanked 6 Times in 2 Posts
MCI is on a distinguished road
I'm going to upload the complete source code to see if that makes it easier to solve the problem.
Reply With Quote
  #8  
Old 06-09-2017, 08:53
felice2011's Avatar
felice2011 felice2011 is offline
Registered User
 
Join Date: Feb 2011
Location: italy
Posts: 836
Thanks: 354
Thanked 1,152 Times in 388 Posts
felice2011 is on a distinguished road
Quote:
Originally Posted by MCI View Post
The problem is that the DLL does not run .... on another PC ... It only works on the PC on which it was written / created
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)
Reply With Quote
  #9  
Old 06-09-2017, 09:06
MCI MCI is offline
Registered User
 
Join Date: Sep 2017
Location: Venezuela
Posts: 9
Thanks: 0
Thanked 6 Times in 2 Posts
MCI is on a distinguished road
Cool

Quote:
Originally Posted by felice2011 View Post
Check that the code creates the same path on another PC and reads and decodes the DLL in the existing path
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.
Reply With Quote
  #10  
Old 06-09-2017, 09:41
kassane's Avatar
kassane kassane is offline
Registered User
 
Join Date: Nov 2011
Location: Somewhere in the World
Posts: 174
Thanks: 578
Thanked 117 Times in 47 Posts
kassane is on a distinguished road
Code:
HANDLE __stdcall MyHandle(void)
{
  return AppHandler;
}
to:
Code:
extern "C" __declspec(dllexport) HANDLE MyHandle(void)
{
  return AppHandler;
}
My Example: using [Inno-Setup 5.5.1 + DLL(MSVC 2017 x86)] Works!
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 11:09. Reason: My example
Reply With Quote
  #11  
Old 06-09-2017, 11:21
MCI MCI is offline
Registered User
 
Join Date: Sep 2017
Location: Venezuela
Posts: 9
Thanks: 0
Thanked 6 Times in 2 Posts
MCI is on a distinguished road
Cool

Quote:
Originally Posted by kassane View Post
Code:
HANDLE __stdcall MyHandle(void)
{
  return AppHandler;
}
to:
Code:
extern "C" __declspec(dllexport) HANDLE MyHandle(void)
{
  return AppHandler;
}
My Example: using [Inno-Setup 5.5.1 + DLL(MSVC 2017 x86)] Works!
Code:
//MyDll.cpp

#pragma once

#ifdef MYDLL_EXPORTS
#define MYDLL __declspec(dllexport) 
#else
#define MYDLL __declspec(dllimport) 
#endif

typedef long int HWND;

extern "C" __declspec(dllexport) HWND Func(void)
{
	return 30*5;
}
not working, same problem occurs
Reply With Quote
  #12  
Old 06-09-2017, 11:58
kassane's Avatar
kassane kassane is offline
Registered User
 
Join Date: Nov 2011
Location: Somewhere in the World
Posts: 174
Thanks: 578
Thanked 117 Times in 47 Posts
kassane is on a distinguished road
Quote:
Originally Posted by MCI View Post
not working, same problem occurs
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
Attached Files
File Type: zip IS_DLLlib.zip (868.9 KB, 29 views)
__________________
"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 04:25. Reason: vcredist2017 x86
Reply With Quote
The Following User Says Thank You to kassane For This Useful Post:
Simorq (08-09-2017)
  #13  
Old 06-09-2017, 12:14
MCI MCI is offline
Registered User
 
Join Date: Sep 2017
Location: Venezuela
Posts: 9
Thanks: 0
Thanked 6 Times in 2 Posts
MCI is on a distinguished road
Cool Thank you..

Quote:
Originally Posted by kassane View Post
Weird! Well, it worked normally here. Did you test my simple example?
The problem seems to have already been resolved. Apparently a bad set up the C ++ compiler.

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 ..
Reply With Quote
The Following User Says Thank You to MCI For This Useful Post:
kassane (06-09-2017)
  #14  
Old 08-09-2017, 07:51
kassane's Avatar
kassane kassane is offline
Registered User
 
Join Date: Nov 2011
Location: Somewhere in the World
Posts: 174
Thanks: 578
Thanked 117 Times in 47 Posts
kassane is on a distinguished road
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.
Reply With Quote
  #15  
Old 08-09-2017, 09:07
MCI MCI is offline
Registered User
 
Join Date: Sep 2017
Location: Venezuela
Posts: 9
Thanks: 0
Thanked 6 Times in 2 Posts
MCI is on a distinguished road
Not Work.

Quote:
Originally Posted by kassane View Post
Update example!
Try it on another pc so you can see that it does not work.
Attached Images
File Type: jpg 1.jpg (65.3 KB, 117 views)
Reply With Quote
Reply

Tags
dll

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
BlackBox v2 y_thelastknight Conversion Tutorials 566 13-10-2023 17:04
INNO TROUBLESHOOT - Tutorials and Answers about INNO Setup REV0 Conversion Tutorials 129 21-05-2021 05:51
Inno Setup: Additional Libraries altef_4 Conversion Tutorials 50 21-10-2020 09:59
Useful Dll for Inno Setup users peterf1999 Conversion Tutorials 88 01-12-2017 16:00
INNO TUTORIAL - Using Unicode and ANSI Versions of INNO Setup REV0 Conversion Tutorials 51 26-03-2015 06:57



All times are GMT -7. The time now is 00:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright 2000-2020, FileForums @ https://fileforums.com