Passing an Integer parameter from .NetCF to embedded VC4 Dll.

P

Prateek

Hi,

I am trying to pass an integer value from .NET CF to evc4 ATL Com dll
function through <dllImport> attribute. As soon as i Pass this value
this value is converted to 0 in evc4. For eg: if i am pass an interger
value 55 thorugh .Net CF, then i receive an interger value 0 in eVC4
dll function.
Can anyone help me out in finding the reason for this behaviour. Below
is the signature for both functions at both ends:


In eVC4 Dll function defination:


#define EXP extern "C" __declspec(dllexport)

EXP int Sample::intValPassTest(int var)
{
/* //Code for converting the integer value to string and see it
through MessageBox in .Net CF
//Shows that integer value 0 is received.

TCHAR arr[5];
wsprintf(arr,TEXT("%d"),var);
MessageBox(NULL,arr,L"emVC4",NULL);
*/

return var;


} ///Class Sample declaration with all function declarations is given
in a Header file which is included in the project.


..Net CF Function.


<DllImport("Sample_ATL_COM.dll",
CallingConvention:=CallingConvention.Winapi, CharSet:=CharSet.Auto,
EntryPoint:="intValPassTest", SetLastError:=True)> _
Public Shared Function intValPassTest(ByVal i As Integer) As
Integer

End Function




And I am calling this function on a button_click event. And its code is
written below:

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click
Try

Dim i As Integer = 55
Dim ii As Integer
ii = intValPassTest(i)
MsgBox(ii) '''msgbox shows 0.


Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub


Any help is appreciated and thanks in advance.
 
P

Paul G. Tobey [eMVP]

Is that a *static* method of a class? If not, what are you passing for the
'this' pointer? If it is a static method, then the declaration is more or
less right, although I'd expect its name to be mangled by the compiler,
since it's in C++.

Paul T.
 
P

Prateek

thanks Paul, I got your point.

I have make the function global and now it is working fine.

Thanks once again.
 

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

Top