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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 

Tags
dll

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 567 11-03-2025 07:16
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 16:25.


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