Solved

DLL DllEntryPoint using data modules

Posted on 2003-10-23
11
204 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

679 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