Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DLL DllEntryPoint using data modules

Posted on 2003-10-23
11
Medium Priority
?
222 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
8 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 500 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

824 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