Warum wirft MSVC++ eine Zugriffsverletzung?
-
Hallo,
Ich habe es hier reingetan, weil ich im Prinzip keine spezielle Frage bezüglich GTKmm ist, sondern die Funktion nutzt ist Windows spezifisch.
ich habe eine Frage, aber erstmal der Quellcode:structs.h
#ifndef _STRUCTS_H_ #define _STRUCTS_H_ struct _HWProps { enum _port{ SERIAL, PS2_KEYBOARD, PS2_MOUSE, USB } port; Glib::ustring COMp; }; enum _PORTS { USB, SERIAL, PS2 }; #endif
hw_props.hpp
#ifndef _HW_PROPS_HPP_ #define _HW_PROPS_HPP_ #include<gtkmm.h> #include"structs.h" #include<Windows.h> #include<string> #include<vector> #include<map> class HPDialog : public Gtk::Dialog { private: _HWProps me; //Gtk::ComboBox pcb; //Gtk::ComboBox fcb; Gtk::Label labels[4]; Gtk::ComboBoxEntryText pcbt; Gtk::ComboBoxEntryText fcb; std::map<Glib::ustring,Glib::ustring> fcontent; protected: bool populate_cd(); DWORD getHID(_PORTS); public: HPDialog(_HWProps); ~HPDialog(){} void on_cbPort_click(); }; #endif
hw_props.cpp
#include"hw_props.hpp" #include<iostream> #include<WinUser.h> HPDialog::HPDialog(_HWProps in) { this->me = in; this->labels[0].set_label("Select Your Connection Mode"); this->get_vbox()->add(this->labels[0]); this->pcbt.append_text("USB"); this->pcbt.append_text("SERIAL"); this->pcbt.append_text("PS/2"); this->pcbt.signal_changed().connect(sigc::mem_fun(*this,&HPDialog::on_cbPort_click)); this->get_vbox()->add(this->pcbt); this->show_all_children(); } void HPDialog::on_cbPort_click() { Glib::ustring t = this->pcbt.get_active_text(); std::cout<<t.c_str()<<std::endl; if(t=="USB") if(this->getHID(_PORTS::USB)!=0) //hier wirft er die Ausnahme raus. std::cout<<"ERROR"<<std::endl; if(t=="SERIAL") if(this->getHID(_PORTS::SERIAL)!=0) std::cout<<"ERROR"<<std::endl; if(t=="PS/2") if(this->getHID(_PORTS::PS2)!=0) std::cout<<"ERROR"<<std::endl; if(this->fcontent.empty()) std::cout<<"CONTENT EMPTY"<<std::endl; } DWORD HPDialog::getHID(_PORTS p) { switch(p) { case _PORTS::USB: RAWINPUTDEVICELIST *tmp; UINT res = GetRawInputDeviceList(tmp,NULL,sizeof(tmp)); for (unsigned short i = 0; i<res;i++) { TCHAR name[99]; UINT cbSize = sizeof(name); if(GetRawInputDeviceInfo(tmp[i].hDevice,RIDI_DEVICENAME,name,&cbSize)>-1) { std::wcout<<name<<std::endl; } } break; } return 0; }
die anderen Codeschnippsel sind hier
http://nopaste.info/b2531f0069.htmlFehlermeldung
Unbehandelte Ausnahme bei 0x000000013F76192D in ROSPOS.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x0000000000000012
Wer kann mir helfen?
Es soll ein POS Programm sein.
Mit freundlichen Grüßen
Sepultura
-
Debugger anwerfen und gucken, wo der unerwartete (ungeprüfte?) Nullzeiger herkommt.
-
Sepultura schrieb:
DWORD HPDialog::getHID(_PORTS p) { switch(p) { case _PORTS::USB: RAWINPUTDEVICELIST *tmp; UINT res = GetRawInputDeviceList(tmp,NULL,sizeof(tmp)); for (unsigned short i = 0; i<res;i++) { TCHAR name[99]; UINT cbSize = sizeof(name); if(GetRawInputDeviceInfo(tmp[i].hDevice,RIDI_DEVICENAME,name,&cbSize)>-1) { std::wcout<<name<<std::endl; } } break; } return 0; }
Das gesamte Handling der RAWINPUTDEVICELIST kommt wir etwas spanisch vor - schau dir noch mal die Doku dazu an - am besten auch ein Beispiel.
-
danke, habe es korrigiert.