what is NotSupportedException in P/Invoke ?

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
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;


}
 
Back
Top