I think this works reliably:
Code: Select all
#include <stdio.h>
#include <string.h>
#include <Windows.h>
#include "..\..\AESImhei.h"
void SendCommand(char* Line) ;
main()
{
long OpenStatus = OpenMHE() ;
if (OpenStatus != 0)
{
printf("IMHEI open failed - %ld\n", OpenStatus) ;
return 0 ;
}
EnableInterface() ;
SendCommand("d ccn") ;
}
void SendCommand(char* Line)
{
struct
{
long Code ;
long Length ;
char Data[128] ;
} Block ;
Block.Code = 0 ;
strcpy(Block.Data, Line) ;
Block.Length = strlen(Block.Data) + 1 ; // include NULL
WriteInterfaceBlock(-1, (char*)&Block, 8 + Block.Length) ;
char Reply[128] ;
while (ReadInterfaceBlock(-1, Reply, 128) == 0)
{
Sleep(1) ;
}
}
Dave