3rd party evc++ dll help

M

M0

Hello,


I am trying to access a function in a 3rd party dll through dllimport


there is a function in the dll called
"epNormalLaunchApp(UInt32 creator);"


and the creator ids can be:
/*
* Common app creator ID's from the header file evc++ def's
*/


#define EP_APP_RX 'nc-2'
#define EP_APP_DX 'nc52'
#define EP_APP_ID 'nc43'
#define EP_APP_TABLE 'ep23'
#define EP_APP_LAB 'ep24'
#define EP_APP_MEDTOOLS 'eMPL'


but the dll crashes when I try to convert the hex of one of these
creator id's into a UInt32 and pass it to the dll, It doesn't crash in

my program see code below but It does crash in the dll with an
exceptioncode of 0x80000002. I am missing something with regards to
the conversion I think but cannot figure out what it is. Any help
would be much appreciated.
Thanks


Mo


---begin code---


<DllImport("epLauncherLib.dll"­, CharSet:=CharSet.Unicode,
EntryPoint:="epNormalLaunchApp­")> _
Public Function MyFunc(ByVal creator As UInt32) As UInt32
End Function


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click


Dim creator As UInt32


creator = System.Convert.ToUInt32(&H6E63­3532)'nc52 in hex


MyFunc(creator)


End Sub


---end code---
 
P

Paul G. Tobey [eMVP]

No need to post multiple times...

Why convert it? Isn't &H6E63­3532 a perfectly valid UInt32?

Paul T.

Hello,


I am trying to access a function in a 3rd party dll through dllimport


there is a function in the dll called
"epNormalLaunchApp(UInt32 creator);"


and the creator ids can be:
/*
* Common app creator ID's from the header file evc++ def's
*/


#define EP_APP_RX 'nc-2'
#define EP_APP_DX 'nc52'
#define EP_APP_ID 'nc43'
#define EP_APP_TABLE 'ep23'
#define EP_APP_LAB 'ep24'
#define EP_APP_MEDTOOLS 'eMPL'


but the dll crashes when I try to convert the hex of one of these
creator id's into a UInt32 and pass it to the dll, It doesn't crash in

my program see code below but It does crash in the dll with an
exceptioncode of 0x80000002. I am missing something with regards to
the conversion I think but cannot figure out what it is. Any help
would be much appreciated.
Thanks


Mo


---begin code---


<DllImport("epLauncherLib.dll"­, CharSet:=CharSet.Unicode,
EntryPoint:="epNormalLaunchApp­")> _
Public Function MyFunc(ByVal creator As UInt32) As UInt32
End Function


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click


Dim creator As UInt32


creator = System.Convert.ToUInt32(&H6E63­3532)'nc52 in hex


MyFunc(creator)


End Sub


---end code---
 
A

Alex Feinman [MVP]

I wonder if the problem is the byte order. Try
creator = System.Convert.ToUInt32(&H3235636E)'nc52 in hex

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello,


I am trying to access a function in a 3rd party dll through dllimport


there is a function in the dll called
"epNormalLaunchApp(UInt32 creator);"


and the creator ids can be:
/*
* Common app creator ID's from the header file evc++ def's
*/


#define EP_APP_RX 'nc-2'
#define EP_APP_DX 'nc52'
#define EP_APP_ID 'nc43'
#define EP_APP_TABLE 'ep23'
#define EP_APP_LAB 'ep24'
#define EP_APP_MEDTOOLS 'eMPL'


but the dll crashes when I try to convert the hex of one of these
creator id's into a UInt32 and pass it to the dll, It doesn't crash in

my program see code below but It does crash in the dll with an
exceptioncode of 0x80000002. I am missing something with regards to
the conversion I think but cannot figure out what it is. Any help
would be much appreciated.
Thanks


Mo


---begin code---


<DllImport("epLauncherLib.dll"­, CharSet:=CharSet.Unicode,
EntryPoint:="epNormalLaunchApp­")> _
Public Function MyFunc(ByVal creator As UInt32) As UInt32
End Function


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click


Dim creator As UInt32


creator = System.Convert.ToUInt32(&H6E63­3532)'nc52 in hex


MyFunc(creator)


End Sub


---end code---
 
M

M0

Alex, I tried the reverse of the byte order as well. Is there another
way to pass a uInt32? I am pretty sure that the only valid UInt32
values are the ones represented by the words below. I apologize for my
lack of knowleedge, I am pretty new to evc++ and .net communication.


#define EP_APP_RX 'nc-2'
#define EP_APP_DX 'nc52'
#define EP_APP_ID 'nc43'
#define EP_APP_TABLE 'ep23'
#define EP_APP_LAB 'ep24'
#define EP_APP_MEDTOOLS 'eMPL'


Thanks

Mo
 
A

Alex Feinman [MVP]

Could you post the part of the .h file where the function itself is defined?
 
M

M0

Below is the .h file I was given for reference.

Thanks again for all your help

Mo
=====================================================================================


#pragma once

// The following ifdef block is the standard way of creating macros
which make exporting
// from a DLL simpler. All files within this DLL are compiled with the
EPLAUNCHERLIB_EXPORTS
// symbol defined on the command line. this symbol should not be
defined on any project
// that uses this DLL. This way any other project whose source files
include this file see
// EPLAUNCHERLIB_API functions as being imported from a DLL, wheras
this DLL sees symbols
// defined with this macro as being exported.
#ifdef EPLAUNCHERLIB_EXPORTS
#define EPLAUNCHERLIB_API __declspec(dllexport)
#pragma message("epLauncherLib - exporting symbols")
#else
#define EPLAUNCHERLIB_API __declspec(dllimport)
#pragma message("epLauncherLib - importing symbols")

#endif

typedef unsigned long UInt32;
typedef int Err ;


#ifdef __cplusplus
extern "C" {
#endif



//Error Codes
typedef enum
{
epErrInternal = -1 ,
epErrSuccess = 0,
epErrAppNotFound ,
epErrInvalidData,
} epErrCodes;


/*
* Common app creator ID's
*/

#define EP_APP_RX 'nc-2'
#define EP_APP_DX 'nc52'
#define EP_APP_ID 'nc43'
#define EP_APP_TABLE 'ep23'
#define EP_APP_LAB 'ep24'
#define EP_APP_MEDTOOLS 'eMPL'



/***********Launching app side****************/

/**
* Launches specified app
*
* @param creator target app creator id
* @param arg target app argument
* @return error for app not found or unable to write argument
* Note: The last element of arg[] MUST be Null.
*/
EPLAUNCHERLIB_API Err epLaunchApp(UInt32 creator, LPCWSTR arg[]);


/**
* Launch target app with normal launch flag
*
* @param creator target app creator id
* @return error for app not found or unable to write argument
*/
EPLAUNCHERLIB_API Err epNormalLaunchApp(UInt32 creator);




#ifdef __cplusplus
}
#endif
 
M

M0

just an update on this, I got this to work in c# using the following
code
========================================================
[DllImport("epLauncherLib.dll", CharSet=CharSet.Auto,
EntryPoint="epNormalLaunchApp")]
public static extern int MyFunc(UInt32 creator);

private void button1_Click(object sender, System.EventArgs e)
{
UInt32 creator = Convert.ToUInt32("6E633532",16); //nc52

MyFunc(creator);

}



===============END CODE=============================

My question now is why the same code will not work in vb.net

any ideas ? :) does this mean c# > vb.net :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top