Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » How to create a U++ based DLL?
How to create a U++ based DLL? [message #38629] Mon, 31 December 2012 02:50 Go to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Is it possible to create a DLL that contains U++ code?

Can you give me an example?

Thanks
Re: How to create a U++ based DLL? [message #38631 is a reply to message #38629] Mon, 31 December 2012 08:38 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3042
Registered: August 2008
Ultimate Member
Hello Lectus

1. In Main package configuration, choose DLL or Dynamic Library.

2. Put this before the function declaration and definition of all the functions that you want to export (call from other program):

extern "C" __declspec(dllexport)


3. Call it Smile


Best regards
Iñaki

[Updated on: Mon, 31 December 2012 08:41]

Report message to a moderator

Re: How to create a U++ based DLL? [message #38640 is a reply to message #38629] Mon, 31 December 2012 19:16 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Thank you!
It worked. I was even able to call U++ functionality from Python using this method.
Re: How to create a U++ based DLL? [message #38686 is a reply to message #38640] Sun, 06 January 2013 16:24 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 269
Registered: June 2010
Location: Spain
Experienced Member
Quote:


3. Call it Smile



How to do it?

Javier
Re: How to create a U++ based DLL? [message #38690 is a reply to message #38686] Mon, 07 January 2013 08:50 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3042
Registered: August 2008
Ultimate Member
281264 wrote on Sun, 06 January 2013 16:24

Quote:


3. Call it Smile



How to do it?

Javier

Hello Javier

If you want to call a function inside a DLL you can do it from another project, a normal .exe.

For that you can do it in different ways. The U++ way is using DLI files. If you want to have low level control you can use the Bazaar/Functions4U way.



Best regards
Iñaki
Re: How to create a U++ based DLL? [message #38694 is a reply to message #38690] Mon, 07 January 2013 16:24 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
koldo wrote on Mon, 07 January 2013 02:50

281264 wrote on Sun, 06 January 2013 16:24

Quote:


3. Call it Smile



How to do it?

Javier

Hello Javier

If you want to call a function inside a DLL you can do it from another project, a normal .exe.

For that you can do it in different ways. The U++ way is using DLI files. If you want to have low level control you can use the Bazaar/Functions4U way.




Also on Windows you can use these functions:
LoadLibrary
http://msdn.microsoft.com/en-us/library/windows/desktop/ms68 4175(v=vs.85).aspx

GetProcAddress
http://msdn.microsoft.com/en-us/library/windows/desktop/ms68 3212(v=vs.85).aspx

Of course it's a non-portable way. Only works in Windows.

It's better to use U++ DLI interface.

[Updated on: Mon, 07 January 2013 16:26]

Report message to a moderator

Re: How to create a U++ based DLL? [message #38787 is a reply to message #38629] Thu, 17 January 2013 20:51 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
I think I found a bug in the DLI interface.

I tried calling a function inside a DLL using the DLI method and I got the error "Heap Leak Detected".

But when I manually call this function using LoadLibrary/GetProcAddress/FreeLibrary I don't get this error.

Maybe DLI is forgetting to call FreeLibrary?
Re: How to create a U++ based DLL? [message #38790 is a reply to message #38787] Fri, 18 January 2013 08:42 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3042
Registered: August 2008
Ultimate Member
Hello Lectus

Could you include a super simple project showing this problem?


Best regards
Iñaki
Re: How to create a U++ based DLL? [message #38791 is a reply to message #38790] Fri, 18 January 2013 14:24 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
koldo wrote on Fri, 18 January 2013 02:42

Hello Lectus

Could you include a super simple project showing this problem?


Hi!
Here it is: http://www57.zippyshare.com/v/71011403/file.html

Build the 3 packages, put test.exe, testwinapi.exe and testdll.dll on the same folder and run them.
Re: How to create a U++ based DLL? [message #38793 is a reply to message #38791] Fri, 18 January 2013 20:06 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3042
Registered: August 2008
Ultimate Member
Hello Lectus

In line 26 I would remove FreeLibrary(hdll) because hdll is NULL.

I am not a DLI expert and I have not found the reason of the problem.

The leak appears only if the function inside the DLL calls the GUI and it is in the PromptOK() call.

Could some DLI expert help us?


Best regards
Iñaki
Re: How to create a U++ based DLL? [message #39123 is a reply to message #38793] Sat, 16 February 2013 21:54 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 269
Registered: June 2010
Location: Spain
Experienced Member
I have tested Dl class in Functions4U and its functions Load and GetFunction both work very well.

Many thanks,

Javier
Re: How to create a U++ based DLL? [message #39135 is a reply to message #39123] Mon, 18 February 2013 08:48 Go to previous message
koldo is currently offline  koldo
Messages: 3042
Registered: August 2008
Ultimate Member
Hello Javier

Excellent. It is just a super simple class handling LoadLibrary/GetProcAddress/FreeLibrary in Windows and the equivalent in Linux. So if you do not need the rest of Functions4U you can just take it.

If you see any improvement please send it Smile


Best regards
Iñaki
Previous Topic: Per file compile flags
Next Topic: Ultimate++ vs WTL and others?
Goto Forum:
  


Current Time: Tue Dec 10 07:30:04 CET 2019

Total time taken to generate the page: 0.02579 seconds