Jump to content
Anna Blanca

Why i can't hide Form1 in DLL?

Recommended Posts

Hello. I'm trying add Form in my DLL, and i hide it with next constraction:

procedure Start;

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.ShowMainForm := False;
Application.Run;
end;

exports
Start;

 Earlier, in previous versions Delphi, my DLL worked normal, but exactly in 12-th Delphi version, all broked. When i launch my library through app, it's working normal, but when i launch through rundll32.exe - no one component on Form1 not working. What Embarcadero broked in this time and how fix it? 

P.S. I attach my project to this topic, you can open it and look all youselfe. 

Fucking DLL.zip

Share this post


Link to post

Your Start() function is not compatible with rundll32. It's a wonder your code ever worked at all. You are invoking undefined behavior.

 

Read: INFO: Windows Rundll and Rundll32 Interface

 

Your Start() function MUST have the following signature in order for rundll32 to call it correctly:

procedure Start(hwnd: HWND; hinst: HINSTANCE; lpszCmdLine: PAnsiChar; nCmdShow: Integer); stdcall;
Edited by Remy Lebeau

Share this post


Link to post
19 hours ago, Remy Lebeau said:

Your Start() function is not compatible with rundll32. It's a wonder your code ever worked at all. You are invoking undefined behavior.

Hm-m-m, earlier, in Delphi 11, all worked normal and my library launched by rundll32.exe normal.

So, and what is HINSTANCE? When i use it in my code, IDE underlining it by red.... No one module in uses not help.

Edited by Anna Blanca

Share this post


Link to post
6 hours ago, Anna Blanca said:

So, and what is HINSTANCE? When i use it in my code, IDE underlining it by red.... No one module in uses not help.

HInstance is the instance (var) of the module, derived from System.pas (type HINST). Should be always defined and available  'cause it is used at loading time (look SysInit.pas)

 

FYI, MainInstance in the HInstance of the MAIN APPLICATION (not the module like dll, library, ...).

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×