The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Problem with accessing DLL Functions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

AndiDC

Germany
Posts

Posted - 06/21/2006 :  05:05:19 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Origin 75G SR5
Operating System: Windows XP SP2
Hi everybody,
although there are some topics concerning function calls from external dll's, I could not solve the following problem:
The following Header file is the interface class (hAnalyseInterface.h):

#ifndef _DEFINED_HANALYSE_DLL_EXPORTS
#define _DEFINED_HANALYSE_DLL_EXPORTS
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned long HANALYSE;
typedef void (__stdcall* LPFN_DLLFUNC_GETVERSION) (char *, char *, char *);

LPFN_DLLFUNC_GETVERSION GetVersionDLL;

#ifdef __cplusplus
}
#endif
#endif//_DEFINED_HANALYSE_DLL_EXPORTS

With the following C++ Code I can access the function without any problem using Visual C++ Compiler (hAnalyseTest.cpp):

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "hAnalyseInterface.h"

int main(int argc, char* argv[])
{
char cVersion, cSubVersion, cSubSubVersion;
char sVersionDLL[]="0.00";

HINSTANCE m_hDll;
HANALYSE hAnalyseHandle=0;

m_hDll=LoadLibrary("hAnalyse.dll");

GetVersionDLL = (LPFN_DLLFUNC_GETVERSION) GetProcAddress(m_hDll, "GetVersionDLL");
GetVersionDLL(&cVersion, &cSubVersion, &cSubSubVersion);

sVersionDLL[0]=48+cVersion;
sVersionDLL[2]=48+cSubVersion;
sVersionDLL[3]=48+cSubSubVersion;

FreeLibrary(m_hDll);

return 0;
}

How can I change the source in an easy way, that I can compile and run it with OriginC?

ML

USA
63 Posts

Posted - 06/28/2006 :  11:49:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try this:


// --------------------------------
// hAnalyseInterface.h:
#ifndef _DEFINED_HANALYSE_DLL_EXPORTS
#define _DEFINED_HANALYSE_DLL_EXPORTS

// Here you may need to provide full path to your DLL:
#pragma dll("hAnalyse.dll")


void __stdcall GetVersionDLL(char *, char *, char *);

#endif//_DEFINED_HANALYSE_DLL_EXPORTS


// END hAnalyseInterface.h
// --------------------------------





// --------------------------------
// Test_hAnalyseInterface.c:
#include <origin.h>
//////////////////////////////////
#include "hAnalyseInterface.h"


void test_hAnalyseInterface()
{
char cVersion, cSubVersion, cSubSubVersion;

GetVersionDLL(&cVersion, &cSubVersion, &cSubSubVersion);

printf("%d.%d%d\n", cVersion + 48, cSubVersion + 48, cSubSubVersion + 48);

}
// END Test_hAnalyseInterface.c
// --------------------------------


I could not test this fully, though, since I don't have your DLL.

You should be able to run the test code from Script Window by calling the test function:

test_hAnalyseInterface

The printf() line will dump the information.


ML

Go to Top of Page

AndiDC

Germany
Posts

Posted - 07/03/2006 :  02:24:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear ML,
thanks for your help!
It worked fine and now I'll try to access the other dll functions!

Regards

Andi
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000