
Signature
Kind regards,
Bruno.
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"
well i'm not using pin_ptr yet, im using this
namespace SknrMV {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Runtime::InteropServices;
[DllImport("C:\\Dll32mv\\Debug\\Dll32din.dll")]
extern "C" void ConServ(int **);
....
more code and
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) {
int *liEstado;
int OtherVal=8;
ConServ(&liEstado); // This is the dll
//OtherVal+= *liEstado;
liEstado=NULL;
}
if i debug the app, i can see how the dll changes the value of &liEstado but
if i try to read the value for example
OtherVal+= *liEstado;
i get the error =(
>> oki doki
>> pin_ptr, im using VC++ managed code, i've passed an int and it works but
[quoted text clipped - 3 lines]
> could you show the bit of code where you pin_ptr the int and call the dll
> function?
Bruno van Dooren - 02 Mar 2006 05:59 GMT
> [DllImport("C:\\Dll32mv\\Debug\\Dll32din.dll")]
> extern "C" void ConServ(int **);
You are using an int **, not an int*. Do you have any idea what the dll is
trying to do there?
> int *liEstado;
> int OtherVal=8;
> ConServ(&liEstado); // This is the dll
> //OtherVal+= *liEstado;
> liEstado=NULL;
You are dereferencing a pointer of which you don't know what it is pointing
to. You didn't initialize it. Do you you what happened with it?

Signature
Kind regards,
Bruno.
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"
Rick - 02 Mar 2006 15:51 GMT
Hi Bruno, i cant find vc6dll.lib, i did exactly the same that your example,
it doesn't crashes anymore but the returned value is wrong, i thought maybe
because vc6dll.lib, i've vs2005 and vs 6.0 in the same pc but not that lib,
or should i built it?
Regards.
>> [DllImport("C:\\Dll32mv\\Debug\\Dll32din.dll")]
>> extern "C" void ConServ(int **);
[quoted text clipped - 11 lines]
> You are dereferencing a pointer of which you don't know what it is
> pointing to. You didn't initialize it. Do you you what happened with it?
Bruno van Dooren - 02 Mar 2006 08:06 GMT
> well i'm not using pin_ptr yet, im using this
>
[quoted text clipped - 20 lines]
>
> }
Hi,
I just tried the following:
VC6 dll:
extern "C"
{
_declspec(dllexport) void _cdecl fun(int** handle);
}
void fun(int** handle)
{
*handle = new int;
**handle = 8;
//yes i know this is a memory leak. it is just an example
}
VC2005 mixed mode WinForms application (/clr):
#pragma unmanaged
extern "C"
{
_declspec(dllimport) void fun(int** handle);
}
#pragma managed
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
int * ptr;
pin_ptr<int*> pptr = & ptr;
fun(pptr);
MessageBox::Show((*ptr).ToString());
}
added vc6dll.lib as a linker input, then built the app and pressed button1.
That shows me the messagebox with text '8'. so if you use the pin_ptr it
should work unless the dll is doing something fishy.
I don't see why it should take an int** if all it wants to do is to give you
an int value. a simple int* would have sufficed for that.
have you checked the documentation for your dll function?

Signature
Kind regards,
Bruno.
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"
Rick - 02 Mar 2006 14:44 GMT
okekis!!
let me try with this sample and i'll tell you what happened
=)
Rick.
Regards.
>> well i'm not using pin_ptr yet, im using this
>>
[quoted text clipped - 62 lines]
>
> have you checked the documentation for your dll function?
Rick - 02 Mar 2006 16:08 GMT
Bruno, it works whit this
[DllImport("C:\\Dll32mv\\Debug\\Dll32din.dll")]
#pragma unmanaged
extern "C"
{
_declspec(dllimport) void ConServ(int *);
}
#pragma managed
----------------------------------------------------------
int ptr;
ConServ(&ptr);
MessageBox::Show((ptr).ToString());
Thanks by your time =D
Rick.
> okekis!!
>
[quoted text clipped - 71 lines]
>>
>> have you checked the documentation for your dll function?