Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

DLL DllEntryPoint using data modules

Posted on 2003-10-23
11
203 Views
Last Modified: 2010-04-03
I have the following code

var
  DllProc: Pointer; { Called whenever DLL entry point is called }
begin
    if DllProc = nil then begin
      DllProc := @DLLEntryPoint;
      DllEntryPoint(Dll_Process_Attach);
    end;


  procedure DLLEntryPoint(Reason: DWORD);
  begin
    case Reason of
      DLL_PROCESS_ATTACH:
        //MessageBox(DLLHandle, 'Process Attach', 'Info', mb_Ok);
        LicenseLoad;
      DLL_PROCESS_DETACH:
        //MessageBox(DLLHandle, 'Process Detach', 'Info', mb_Ok);
        LicenseFree;
    end;                                          // case
  end;

function LicenseLoad: boolean;
var
 st : TStream;
begin
  dmData := TdmData.Create(nil); <<<< STOPS HERE
  GenerateMachineId; // generate a machine id
  dmData.tblLicense.First;
  st := dmData.tblLicense.CreateBlobStream(dmData.tblLicense.FieldByName('Key'),bmRead);
  result := LoadLicenseStream(st);
  st.free;
end;

The only problem is that when you try this it stops in creating the tmdata object. This is when using LoadLibrary to load the dll, if you call the code directly then it works



0
Comment
Question by:jeffborg
  • 6
  • 2
11 Comments
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 9612213
do you have any code in the datamodules constructor
or any "Active" components
debug the datamodules constructor to see what happens

also what delphi version u using
6 and above descend the TDataModule from TComponent so this shouldn't be a problem
0
 

Author Comment

by:jeffborg
ID: 9612239
Yes there is code in the datamodule on the ModuleCreate event. But it dosen't get there. also it's delphi 7

Also the code dosen't even get there. It just stops at the line mentioned.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 9612258
do you have any datasets with Active set to true or anything similar ?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:jeffborg
ID: 9612260
The datasets get set to active via my code which initializes the datamodule.

This all worked fine before I started to Call the function listed above from the dllentrypoint.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 9612303
weird ... I'll create a test dll to check this out
maybe vcl is fuxored :)
0
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 250 total points
ID: 9612349
:)

var
  DllProc: Pointer; { Called whenever DLL entry point is called }


why did you declare it ? it's a global var in SysInit :)
just noticed this
anyway this shouldn't have any effect on the processattach entry
only the processdetach would never be called in your code

I have no problems with my datamodule (using a ClientDataSet)

some other component on your datamodule must be causing the problem
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 12294727
is there a new grading policy ? the grade C doesn't really smell that good .. but I understand why the C in such cases
in the future I might object to being awarded the points with such a grade :)
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 12305404
ooooh .. sorry kacor, thought it was a forced accept .. my bad :)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question