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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Problem with accessing DLL Functions

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AndiDC Posted - 06/21/2006 : 05:05:19 AM
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?
2   L A T E S T    R E P L I E S    (Newest First)
AndiDC Posted - 07/03/2006 : 02:24:11 AM
Dear ML,
thanks for your help!
It worked fine and now I'll try to access the other dll functions!

Regards

Andi
ML Posted - 06/28/2006 : 11:49:58 AM
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


The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000