Solved

DLL DllEntryPoint using data modules

Posted on 2003-10-23
11
195 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now