PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Help!!!

Reply

Help!!!

 
Thread Tools Rate Thread
Old 24-02-2005, 02:40 AM   #1
morice
Guest
 
Posts: n/a
Default Help!!!


I have writen a dll(EmrCmprs.dll) using c++ and a function in this DLL:

__declspec(dllexport) long EmrDecompress( char *pcCompressData /*in*/,
long lCompressDataSize/*in*/,
char **ppcRawData/*unicode out*/,
long *plRawDataSize/*out*/ )
{
...
}

Then,i invoke the function(EmrDecompress) in dotframework:

[DllImport("EmrCmprs.dll")]
private static extern int EmrDecompress_BYTE(
byte[] pSrc,
int iSrcLen,
[MarshalAs(UnmanagedType.LPWStr)]
ref string pDst,
ref int iDstLen );

private void Test_Click(object sender, System.EventArgs e)
{
byte[] pSrc ;
int iSrcLen;
string pDst = null;
int iDstLen = 0;

try
{
// -- open file
FileStream fsRead = new FileStream(@"c:\chu0.DAT" ,
FileMode.Open , FileAccess.Read ,
FileShare.ReadWrite);

// -- get data
iSrcLen = (int)fsRead.Length;
pSrc = new byte[fsRead.Length];
fsRead.Read(pSrc , 0 , (int)fsRead.Length);

// -- close file
fsRead.Close();


int iResult = EmrDecompress(pSrc,iSrcLen,ref pDst,ref iDstLen);


if(iResult != 0)
{
throw new Exception("Decompress is failed!");
}
}
catch (Exception ex)
{
throw ex;
}
}

But i get error pDst and right iDstLen!
(In C++,the function of EmrDecompress do right thing.)
I think the following parameter is not right:
[MarshalAs(UnmanagedType.LPWStr)]
ref string pDst
but how to modify it ?
I try again and again,but failed!

Can you help me?

Thanks in advance!

Morice


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off