Help with some C programming (1 Viewer)

mikhail

Senior Member
Jan 24, 2003
9,576
#1
Guys, I'm having some trouble with some code. IT's supposed to read in from a parallel port, and it's using the io.dll from this site. :down:

To get it to work with another bit of code, it has to be able to compile when you right-click on the text, select "TargetExpert", then in the "Platform" menu select "DOS (Standard). Now check the "BGI" box under "Libraries".

PHP:
void UnloadIODLL();
int LoadIODLL();

#include "io.h"
#include <stdio.h>
#include <stdlib.h>

PORTWORDIN PortWordIn; 
HMODULE hio;    

void main(void){
   char cont;
   int input;

   input = LoadIODLL();
   if(input == 1)
   {
      printf("\n\nError: Cannot load library...\n\nProgram ends.");
      exit(0);
   }

   do
   {
      input = PortWordIn(379);
      printf("Port word in is %d", input);
      getchar();
      printf("\nAnother? (y/n) ");
      scanf("%c", &cont);
   }while((cont == 'y') || (cont == 'Y'));

   UnloadIODLL();
}


void UnloadIODLL() {
   FreeLibrary(hio);
}

int LoadIODLL() {
   hio = LoadLibrary("io");
   if (hio == NULL) return 1;

   return 0;
}
 

Buy on AliExpress.com

Martin

Senior Member
Dec 31, 2000
56,913
#2
So you're writing device drivers now? :D

Sorry, don't speak a word of C. Yes, I know I'm incredibly lame.. :doh::D

Someone else might know though.. Majed? Loppan? Graham? Reza?
 

gray

Senior Member
Moderator
Apr 22, 2003
30,260
#3
I only did a semester of C, so that's a bit too advanced for me :down::embarass:
 

Reza

Junior Member
Jul 13, 2002
266
#4
i don't really know where is u'r problem ,
i didn't test the code but if u have trouble loading library and using functions , try another ways like linking with static library or using windows loadlibrary mechanism.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)