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 » Developing U++ » External resources » DLLs
DLLs [message #18689] Fri, 17 October 2008 08:46 Go to next message
darki699 is currently offline  darki699
Messages: 3
Registered: October 2008
Location: Hell
Junior Member
I usually program in VC++ or VC#
Lately I tried UPP and liked it since it resolves the annoying GUI building frustration.

One thing troubles me tho...

I can't seem to attach DLLs to a UPP project.

For example, I created a crawler in c# and I tried to attach it to the UPP GUI code I created by making the crawler "MediaInfo.dll"

In VC++ you only need to attach the namespace such as

#using<MediaInfo.dll>

but in UPP????

Since #using is not valid without the /clr option, and upp is not using the managed c++ options, how can i change this?

In other words, is there any way to attach my dll?
Re: DLLs [message #18690 is a reply to message #18689] Fri, 17 October 2008 09:48 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Static binding is aavilable through attaching DLL`s .lib file if you have one. Dynamic binding is discussed in this topic.
Re: DLLs [message #18692 is a reply to message #18689] Fri, 17 October 2008 13:23 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
The problem is that you want to use a .NET DLL from native C++ code. It is not so trivial, I think. You have to study MSDN.
Re: DLLs [message #18705 is a reply to message #18689] Fri, 17 October 2008 18:12 Go to previous messageGo to next message
darki699 is currently offline  darki699
Messages: 3
Registered: October 2008
Location: Hell
Junior Member
C# is using classes rather than functions in the dll file.
So I didn't quite understand how *.dli file could solve my problem since it's function based and not class based.

C# actually creates a *.class file name (like in java), so I need to access a class Crawler in some way by linking my MediaLink.dll .

To be more specific, in managed VC++ I would normally type:

#include <iostream>
#using <mscorlib.dll>
#using <MediaLink.dll> // name of the dll which contains the C# code for the Crawler class

using namespace System;
using namespace System::Collections;
using namespace std;

void main(void)
{
Crawler c;
c.CrawlToSite("http://www.ultimatepp.org/forum/");
}


But how can I create a DLI file for something like this?
Re: DLLs [message #18706 is a reply to message #18705] Fri, 17 October 2008 18:40 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

You can`t. If you want to import CLR classes (not native functions) I don`t know how to help you, sorry.
Hope google will help on searching.
Re: DLLs [message #18719 is a reply to message #18689] Sat, 18 October 2008 17:28 Go to previous messageGo to next message
zaurus is currently offline  zaurus
Messages: 42
Registered: May 2006
Member
I had a similar problem some time ago, when I had to integrate a third party .NET DLL. After many days and nights googleing I found that there is a way by acessing the DLL via DCOM.

In your .NET DLL you need to expose an Interface.

using System.Runtime.InteropServices;

namespace TestClass
{
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface ITestInterface
    {
        bool Function1OfDLL(string sParameter);
        string Function2OfDLL(string sAnotherParameter);
    }
    public class TestClass : ITestInterface
    {
        public TestClass()
        {
            //Init code;
        }

        bool Function1OfDLL(string sParameter);
        {
            //Do something here
        }
        string Function2OfDLL(string sAnotherParameter);
        {
            //Do something here
        }
     }
}


Then you need to register your DLL with "RegAsm.exe TestDLL.dll". The RegAsm tool is part of the .NET-Framework.

In VC++ 6.0 is goes like this to access the DLL. Something similar should be possible in U++.

#import "TestDLL.tlb"
using namespace TestClass;
HRESULT hr = CoInitialize(NULL);
ITestInterface* m_DLL;
m_DLL = NULL;
CLSID clsid;
REFIID refiid =  __uuidof(ITestInterface);
hr = CLSIDFromProgID(OLESTR("TestDLL.TestClass"), &clsid);
hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, refiid, (LPVOID*) &m_DLL);

Access functions of DLL.

m_DLL->Funtion1OfDLL();


To close connection with DLL do this.

m_DLL->Release();
CoUninitialize();


I hope this helps.

Good luck.

Zaurus
Re: DLLs [message #19305 is a reply to message #18719] Tue, 25 November 2008 10:31 Go to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Good article for plug-in architecture is here!
If is other better ideas... I will be glad to discuss about this!
Previous Topic: MSC9x64
Next Topic: How to use Clutter script?
Goto Forum:
  


Current Time: Thu Mar 28 22:34:56 CET 2024

Total time taken to generate the page: 0.01752 seconds