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
Re: DLLs [message #18719 is a reply to message #18689] Sat, 18 October 2008 17:28 Go to previous messageGo to previous 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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MSC9x64
Next Topic: How to use Clutter script?
Goto Forum:
  


Current Time: Wed May 08 03:53:07 CEST 2024

Total time taken to generate the page: 0.01510 seconds