what is NotSupportedException in P/Invoke ?

N

news.microsoft.com

API :

int HHRecognize(short* pTrace, WORD* pResult, int nCand, long wRange )



----------------------------------------------------------------------------
---------------

Sample.c :

#include "hw.h"



void main( void )

{

WORD wTrace[8] = { 0x0010, 0x0010, 0x0020, 0x0010, 0xffff, 0, 0xffff,
0xffff };

WORD szResult[20];

int num = 0;



num = HWRecognize( wTrace, szResult, 10, 1 );



if( num )

{

//result in "szResult"

//you may add code here

}

else

{

//no result

}

}





----------------------------------------------------------------------------
---------------------



I write c# code here :



[DllImport("HHRES.dll", EntryPoint="HHRecognize", SetLastError=true)]
internal static extern int HHRecognize(UInt16[] pTrace, out UInt16[]
pResult, int nCand, long nAlc );



public static UInt16[] myFunction() {
UInt16[] Trace={ 0x0010, 0x0010, 0x0020, 0x0010, 0xffff, 0, 0xffff,
0xffff };

UInt16[] myResult ;
int num = 0;
try {
num =HWRecognize(Trace, out myResult, 10, 1);}
catch (NotSupportedException ex) {
Console.Write(ex.Message);
}

if(Convert.ToBoolean(num) ){
//result in "szResult"
//you may add code here

}
else {
//no result
}
return myResult;


}
 

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