mainwindow.hpp:
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <QApplication>
#include <QMainwindow>
#include <QTextCodec>
#include <QPushButton>
#include <QLabel>
#include <QMenuBar>
#include <QStatusBar>
#include <windows.h>
typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);
class MainWindow : public QMainWindow
{
Q_OBJECT
private:
QPushButton *button;
QPushButton *port2;
QPushButton *port1;
QPushButton *port3;
QLabel *label;
QMenu *menu;
QAction *quitAction;
void createMenus();
void createStatusBar();
public:
MainWindow();
private slots:
int lpt1();
};
#endif // MAINWINDOW_HPP
main.cpp:
#include <QApplication>
#include <QMainWindow>
#include "mainwindow.hpp"
int main (int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow window;
window.show();
return app.exec();
}
mainwindow.cpp:
#include "mainwindow.hpp"
MainWindow::MainWindow()
{
QTextCodec::setCodecForTr (QTextCodec::codecForName ("Windows-1250"));
label = new QLabel(tr("Jakis napis"), this);
label->setGeometry(5, 5, 150, 30);
port1 = new QPushButton(tr("&Port 1"), this);
port1->setGeometry(5, 75, 100, 30);
port2 = new QPushButton(tr("&Port 2"), this);
port2->setGeometry(5, 105, 100, 30);
port3 = new QPushButton(tr("&Port 3"), this);
port3->setGeometry(5, 135, 100, 30);
connect(port1, SIGNAL(clicked()), this, SLOT(lpt1()));
setMinimumSize(200, 200);
resize(480, 320);
}
int MainWindow :: lpt1()
{
//***********************************************************
//uchwyt dll-ki oraz wskazniki do funkcji
HINSTANCE hLib;
oupfuncPtr OutPort;
hLib = LoadLibraryA("inpout32.dll");
OutPort = (oupfuncPtr) GetProcAddress(hLib, "Out32");
//***********************************************************
OutPort(0x378, 00000001); //wyslanie danej
system("PAUSE");
OutPort(0x378, 00000000); //wyslanie danej
system("PAUSE");
OutPort(0x378, 2); //wyslanie danej
system("PAUSE");
OutPort(0x378, 00000000); //wyslanie danej
system("PAUSE");
OutPort(0x378, 4); //wyslanie danej
system("PAUSE");
OutPort(0x378, 00000000); //wyslanie danej
system("PAUSE");
OutPort(0x378, 8); //wyslanie danej
system("PAUSE");
OutPort(0x378, 00000000); //wyslanie danej
system("PAUSE");
OutPort(0x378, 16); //wyslanie danej
system("PAUSE");
OutPort(0x378, 32); //wyslanie danej
//***********************************************************
FreeLibrary (hLib); //zwolnienie dll-ki
system("PAUSE");
return EXIT_SUCCESS;
}
Po skompilowaniu i uruchomieniu programu oraz naciśnięciu przycisku "Port 1" wyskakuje błąd windowsowy "Wystąpił problem z aplikacją nienazwany2.exe i zostanie ona zamknięta. Przepraszamy za kłopoty. System - Windows XP SP3, korzystam z qt creatora. Gdzie popełniłem błąd?