Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DLL DllEntryPoint using data modules

Posted on 2003-10-23
11
Medium Priority
?
216 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
[X]
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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

721 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