Anna Blanca 1 Posted Wednesday at 02:32 AM 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
Remy Lebeau 1621 Posted Wednesday at 04:46 AM (edited) 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 Wednesday at 04:52 AM by Remy Lebeau Share this post Link to post
Anna Blanca 1 Posted Wednesday at 11:51 PM (edited) 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 Wednesday at 11:52 PM by Anna Blanca Share this post Link to post
DelphiUdIT 248 Posted Thursday at 06:56 AM 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
Anna Blanca 1 Posted Thursday at 01:18 PM 6 hours ago, DelphiUdIT said: FYI, MainInstance in the HInstance of the MAIN APPLICATION (not the module like dll, library, ...). In this case, my DLL is main application. So, what library i must add in uses? And i want message you, if my DLL launch normal, when i not hide Form1, when i not use Application.ShowMainForm := False; Share this post Link to post
Cristian Peța 122 Posted Thursday at 01:38 PM 12 minutes ago, Anna Blanca said: my DLL is main application A DLL is a library and it can run only in the processes of a main application (rundll32 or other app). Share this post Link to post
Remy Lebeau 1621 Posted Thursday at 03:42 PM (edited) 17 hours ago, Anna Blanca said: Hm-m-m, earlier, in Delphi 11, all worked normal and my library launched by rundll32.exe normal. "Seeming to work fine" is a possible result of Undefined Behavior. That doesn't mean the code was right, though. rundll32 requires a very specific signature for the entry point function that it calls, and your code was not satisfying that requirement. Fix that first, and if your UI problem still occurs then we can focus on that next. 17 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. Sorry, I keep forgetting that Delphi doesn't define HINSTANCE as a type. Use System.HINST or Winapi.Windows.HINST or THandle instead. Edited Thursday at 05:21 PM by Remy Lebeau Share this post Link to post
DelphiUdIT 248 Posted Thursday at 03:57 PM (edited) 26 minutes ago, Remy Lebeau said: Sorry, I keep forgetting that Delphi doesn't define HINSTANCE. Use System.HINST or Winapi.Windows.HINST or THandle instead. I wrote that, HINSTANCE is a global var. HINST is the type. Edited Thursday at 04:09 PM by DelphiUdIT Share this post Link to post
DelphiUdIT 248 Posted Thursday at 03:59 PM 16 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. Edited 15 hours ago by Anna Blanca Share this post Link to post
DelphiUdIT 248 Posted Thursday at 09:02 PM This are the project. Fucking DLL RUNDLL32.zip Share this post Link to post