PDA

View Full Version : [Win] Problems with PIP_ADAPTER_ADDRESSES



Doles
19th June 2008, 18:04
Hi all,
I`m brand-new Qt programmer. I`ve written my first serious program. It is a kind of network monitor, very simple just shows basic informations such as IP, Broadcast etc. On Linux it works correctly but on Windows I get the GUID numbers in QComboBox (on Linux of course there are names like a "eth0" or "lo"). I decided to use some WinAPI functions to convert this numbers to normal ASCII name. But of course now I have some problems with my source code. When I fire up "make" i get this message:

qip.h:77: error: `PIP_ADAPTER_ADDRESSES` does not a name of type

I don`t know what is wrong. This is my source code:
File: qip.h
http://paste.org/index.php?id=3096

File: qip.cpp
http://paste.org/index.php?id=3097

And this is the QIP.pro file:

################################################## ####################
# Automatically generated by qmake (2.01a) Cz 19. cze 15:49:43 2008
################################################## ####################

TEMPLATE = app
TARGET =
DEPENDPATH += . release
INCLUDEPATH += .

# Input
HEADERS += qip.h \
c:\mingw\include\iphlpapi.h \
c:\mingw\include\winsock2.h
FORMS += qip.ui
SOURCES += main.cpp qip.cpp
RESOURCES += qipresources.qrc
TRANSLATIONS += trans_pl.ts
QT += network
RC_FILE = qip_resource.rc

I don`t sure that my idea was good. Maybe there is more convenient and smart way
Regards,
Bartek

Doles
20th June 2008, 19:18
Ok guys I was trying to fix up this problem, but realised that it is impossible to connect Qt with functions from <iphlpapi.h> maybe with WinAPI at all :(

marcel
20th June 2008, 19:40
you should take a look at this: http://msdn.microsoft.com/en-us/library/aa365915(VS.85).aspx.

You can use WinAPI code in a Qt application without problems.
PIP_ADAPTER_ADDRESSES is a pointer to IP_ADAPTER_ADDRESSES...maybe you don;t have that defined.

Anyway, QNetworkInterface already contains the support for getting all the interfaces, although it does not seem to return their friendly names on Windows. For this purpose you can use GetAdaptersAddresses.

Doles
21st June 2008, 00:41
I`ve already known that, I should use this function from MSDN, but I have troubles during working with this function. Ok now I changed PIP_ADAPTER_ADDRESSES to "struct IP_ADAPTER_ADDRESSES* " and I have following errors:

qip.cpp: In member function `void QIP::createNetworkList()':
qip.cpp:57: error: `AF_UNSPEC' undeclared (first use this function)
qip.cpp:57: error: (Each undeclared identifier is reported only once for each fu
nction it appears in.)
qip.cpp:57: error: `GAA_FLAG_INCLUDE_PREFIX' undeclared (first use this function
)
qip.cpp:57: error: `GetAdaptersAddresses' undeclared (first use this function)
qip.cpp:57: error: `ERROR_BUFFER_OVERFLOW' undeclared (first use this function)
qip.cpp:59: error: `GetProcessHeap' undeclared (first use this function)
qip.cpp:59: error: `HeapFree' undeclared (first use this function)
qip.cpp:60: error: `HeapAlloc' undeclared (first use this function)
qip.cpp:62: error: `NO_ERROR' undeclared (first use this function)
qip.cpp:68: error: invalid use of undefined type `struct IP_ADAPTER_ADDRESSES'
qip.h:77: error: forward declaration of `struct IP_ADAPTER_ADDRESSES'
qip.cpp:69: error: invalid use of undefined type `struct IP_ADAPTER_ADDRESSES'
qip.h:77: error: forward declaration of `struct IP_ADAPTER_ADDRESSES'
mingw32-make[1]: *** [release/qip.o] Error 1
mingw32-make[1]: Leaving directory `C:/Documents and Settings/Bartek/Moje dokume
nty/0.2'
mingw32-make: *** [release] Error 2

C:\Documents and Settings\Bartek\Moje dokumenty\0.2>
I really don`t know what is going on. It seems to doesn`t know anything about declarations from iphlpapi.h and winsock2.h.