qint32 MainWindow::connectGPRS(QString connectionName){ RASDIALPARAMS RDP; HRASCONN HRC = NULL; RDP.dwSize=sizeof(RDP); wcscpy(RDP.szEntryName,(const wchar_t*)connectionName.utf16()); int Pass; int res=RasGetEntryDialParams(NULL,&RDP,&Pass); if (res!=ERROR_SUCCESS) { return -1; } else { RDP.dwSize=sizeof(RDP); qDebug()<<QString("connectGPRS: user: %1").arg(QString::fromUtf16((ushort*)((RDP.szUserName)))); res=RasDial(0,0,&RDP,0,[color=red]&slot_GPRS_timer()[/color],&HRC); if (res!=ERROR_SUCCESS) { qDebug()<<QString("Error RasDial: %1").arg(res); RasHangUp( HRC ); return -1; } else { qDebug()<<QString("RasDial: OK%1").arg((qint32)(HRC)); return 1; } } return 1;}
: error: lvalue required as unary '&' operand
public slots: void slot_GPRS_timer();
res=RasDial(0,0,&RDP,0,&slot_GPRS_timer,&HRC);
C++ (Qt)static void slot_GPRS_timer();
C++ (Qt)class MainWindow : ...{ static void slot_GPRS_timer(); ... res=RasDial( 0, 0, &RDP, 0, &MainWindow::slot_GPRS_timer, &HRC );
void WINAPI MainWindow::RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError){ QString S = ""; if (dwError) { // Error occurred, show the error string. wchar_t buff[256]; RasGetErrorString( dwError, buff, sizeof(buff)); return; } switch (rascs) { // Build a status string based on the // status message. case RASCS_PortOpened : S = "Port opened..."; break; case RASCS_DeviceConnected : S = "Connected..."; break; case RASCS_Authenticate : S = "Logging on..."; break; case RASCS_Authenticated : S = "Authenticated"; break; case RASCS_Connected : S = "Logon Complete"; break; case RASCS_Disconnected : S = "Disconnected"; break; } qDebug() << S; }
делал static он говорит что должен быть без статикаDWORD res = RasDial( 0, 0, ¶ms, 1, RasCallback, &hRas);
#ifdef Q_OS_WIN32 #include "windows.h" #include "wingdi.h" #include "winuser.h" #include "psapi.h" #include "winsvc.h" #include "shellapi.h" #include "ras.h" #include "tchar.h" #include "raserror.h" #include "rasdlg.h" #include "winreg.h"#else#endif
private: // qint32 connectGPRS(QString connectionName); qint32 disconnectGPRS();public: void WINAPI RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError);
void WINAPI MainWindow::RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError){ QString S = ""; if (dwError) { // Error occurred, show the error string. wchar_t buff[256]; RasGetErrorString( dwError, buff, sizeof(buff));// return ; } switch (rascs) { // Build a status string based on the // status message. case RASCS_PortOpened : S = "Port opened..."; break; case RASCS_DeviceConnected : S = "Connected..."; break; case RASCS_Authenticate : S = "Logging on..."; break; case RASCS_Authenticated : S = "Authenticated"; break; case RASCS_Connected : S = "Logon Complete"; break; case RASCS_Disconnected : S = "Disconnected"; break; } qDebug() << S; // Show the status message in the memo.// if (S != "")// Form1->Memo1->Lines->Add(S);}qint32 MainWindow::connectGPRS(QString connectionName){ RASDIALPARAMS RDP; HRASCONN HRC = NULL; RDP.dwSize=sizeof(RDP); wcscpy(RDP.szEntryName,(const wchar_t*)connectionName.utf16()); int Pass; int res=RasGetEntryDialParams(NULL,&RDP,&Pass); if (res!=ERROR_SUCCESS) { return -1; } else { RDP.dwSize=sizeof(RDP); qDebug()<<QString("connectGPRS: user: %1").arg(QString::fromUtf16((ushort*)((RDP.szUserName)))); res=RasDial(0,0,&RDP,1,MainWindow::RasCallback,&HRC); if (res!=ERROR_SUCCESS) { qDebug()<<QString("Error RasDial: %1").arg(res); RasHangUp( HRC ); return -1; } else { qDebug()<<QString("RasDial: OK%1").arg((qint32)(HRC)); return 1; } } return 1;}
C++ (Qt)class MainWindow : ...{ static void RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError); ... res = RasDial( 0, 0, &RDP, 0, (void*)&MainWindow::RasCallback, &HRC );
static void MainWindow::RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError){ .... }
error: cannot declare member function 'static void MainWindow::RasCallback(HRASCONN__*, UINT, RASCONNSTATE, DWORD, DWORD)' to have static linkage
void MainWindow::RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError){ .... }
C++ (Qt)void MainWindow::RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError){ .... }
static void WINAPI RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError);
void WINAPI MainWindow::RasCallback(HRASCONN hrasconn, UINT unMsg, RASCONNSTATE rascs, DWORD dwError, DWORD dwExtendedError){...}res=RasDial(0,0,&RDP,1,(void*)MainWindow::RasCallback,&HRC);