so ich hab es geschafft in C compiliert sind das dann 17kB
komfortabel auch mit lesefunktion !!
für die anwendungen die ich benötige sollte ich doch besser nach c wechseln
komme ja von basic (BASCOM)
und arbeite auch hauptsächlich damit nur halt die PC GUI schreibe ich in Python da pygame und Blender sehr interesant sind
und ich mit pointern seit dem studium
4 anläufe für C semester1schein
und 3 anläufe für java semester2schein
AUF KRIEGSFUSS STEHE
wie das beispiel zeigt diees hier dauerte locker 10std suche im netz und mindestens 50 eher 100 compilierungsfehler bis zum run!!!
Code: Alles auswählen
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
/* Definitions in the build of inpout32.dll are: */
/* short _stdcall Inp32(short PortAddress); */
/* void _stdcall Out32(short PortAddress, short data); */
/* prototype (function typedef) for DLL function Inp32: */
typedef short (_stdcall *inpfuncPtr)(short portaddr);
typedef void (_stdcall *oupfuncPtr)(short portaddr, short datum);
#define PPORT_BASE 0x378
void test_write(void);
void test_read_control(void);
/* After successful initialization, these 2 variables
will contain function pointers.
*/
inpfuncPtr inp32fp;
oupfuncPtr oup32fp;
/* Wrapper functions for the function pointers
- call these functions to perform I/O.
*/
short Inp32 (short portaddr)
{
return (inp32fp)(portaddr);
}
void Out32 (short portaddr, short datum)
{
(oup32fp)(portaddr,datum);
}
int main(void)
{
HINSTANCE hLib;
short x;
int i;
/* Load the library */
hLib = LoadLibrary("inpout32.dll");
if (hLib == NULL) {
fprintf(stderr,"LoadLibrary Failed.\n");
return -1;
}
/* get the address of the function */
inp32fp = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
if (inp32fp == NULL) {
fprintf(stderr,"GetProcAddress for Inp32 Failed.\n");
return -1;
}
oup32fp = (oupfuncPtr) GetProcAddress(hLib, "Out32");
if (oup32fp == NULL) {
fprintf(stderr,"GetProcAddress for Oup32 Failed.\n");
return -1;
}
/*******************************************************/
/** IF WE REACHED HERE, INITIALIZED SUCCESSFUL ******/
/*******************************************************/
//test_read_control();
test_write();
//test_read_control();
/* finished - unload library and exit */
FreeLibrary(hLib);
//system("pause");
return 0;
}
// TEST: Write constant to Control register)
void test_write(void) {
short x;
int i;
Out32(0x37A,0xCA); // Set Output-only again
}
// TEST: READ data from control
void test_read_control(void) {
short x;
int i;
i=0x37A;
x = 12;
x = Inp32(i);
printf("Port read (%04X)= %04X\n",i,x);
}
Edit by Gerold: Code-Tag von "Python" nach "C" geändert