"Proper" way to Interop with Unmanaged Dll



Hi... I have the following (and many more) functions I need to use

MC_STATUS MC_Register_Application(int* ApplicationID, char* AEtitle);

I'm trying to access this function from c#, from my reading I have come
up with 2 possible ways to do this by creating a managed c++ wrapper...

//////////////////////////////////////////////////////////////
// 1)

__gc public class CMergeInterop
{
[DllImport("mc3adv.dll")]
static MC_STATUS MC_Register_Application(Int32* ApplicationID,
[MarshalAs(UnmanagedType::LPStr)]String* AEtitle);
}

//////////////////////////////////////////////////////////////
// 2)

#pragma unmanaged
[DllImport("mc3adv.dll")]
extern MC_STATUS MC_Register_Application(int* ApplicationID, char*
AEtitle);

#pragma managed
__gc public class CMergeInterop
{
tatic MC_STATUS MC_Register_Application(Int32* ApplicationID, String*
AEtitle)
{
IntPtr aParam1;
aParam1 = Marshal::AllocHGlobal(sizeof(int*));
IntPtr aString;
aString = Marshal::StringToHGlobalAuto(AEtitle);
MC_STATUS eStatus =
::MC_Register_Application((int*)aParam1.ToPointer(),
(char*)aString.ToPointer());
*ApplicationID = (int)(aParam1);
Marshal::FreeHGlobal(aParam1);
Marshal::FreeHGlobal(aString);
return eStatus;
}
}

or
//////////////////////////////////////////////////////////////
// 3) some other way

Which is the (A) Preferred Way (B) Correct Way (C) Most Efficient Way

Thanks
bv

.