mac address
- Antonio Linares
- Site Admin
- Posts: 42450
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 20 times
- Been thanked: 58 times
- Contact:
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
Antonio,
I think I found the reason why it´s sometimes working and sometimes not.
It seems to depend on the pc the app is compiled. Compiling it with my office pc (XP64) it only runs on this pc, on others it crashes without error log, only a system message that there is a problem with he app.
If I compile it on my home pc (xp32, Sp3) it working on verey other pc.
I nerver noticed this before, I have the same version, the same environment, it´s very curious.
I think I found the reason why it´s sometimes working and sometimes not.
It seems to depend on the pc the app is compiled. Compiling it with my office pc (XP64) it only runs on this pc, on others it crashes without error log, only a system message that there is a problem with he app.
If I compile it on my home pc (xp32, Sp3) it working on verey other pc.
I nerver noticed this before, I have the same version, the same environment, it´s very curious.
kind regards
Stefan
Stefan
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
Antonio,
sorry, I forgot to insert these lines
before pAdapterInfo = pAdapterInfo->Next;. Now it´s working.
It returns the description, the mac address, it´s name and it´s type for every card.
here is an small sample
Only one problem remains, the description and the name are PWCHAR in the API-deklaration, with
hb_arraySet(pSubArray, 1, hb_itemPutC(pItem,( char *) pAdapterInfo->Description));
I get only the first char back. How can I convert this type into a PCHAR ?
This function is returning an empty array here on my computer.
sorry, I forgot to insert these lines
Code: Select all | Expand
hb_arrayAdd(paAddress, pSubArray);
hb_itemRelease(pSubArray);
before pAdapterInfo = pAdapterInfo->Next;. Now it´s working.
It returns the description, the mac address, it´s name and it´s type for every card.
here is an small sample
Code: Select all | Expand
FUNCTION GetNetID3 ()
LOCAL n
LOCAL cDescription, cMac, cType, cName
LOCAL aNic := GetMac ()
if ValType (aNic ) == "A"
for n := 1 TO Len (aNic)
cDescription := aNic [n,1]
cMac := aNic [n,2]
cName := aNic [n,3]
cType := cValToChar (aNic [n,4])
IF cType = "6"
MsgInfo( "Description: "+cDescription+CRLF+;
"Mac : "+cMac+CRLF+;
"Name : "+cName+CRLF+;
"Type : "+cType,;
"NIC" )
endif
next
endif
RETURN (nil)
Only one problem remains, the description and the name are PWCHAR in the API-deklaration, with
hb_arraySet(pSubArray, 1, hb_itemPutC(pItem,( char *) pAdapterInfo->Description));
I get only the first char back. How can I convert this type into a PCHAR ?
kind regards
Stefan
Stefan
- Antonio Linares
- Site Admin
- Posts: 42450
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 20 times
- Been thanked: 58 times
- Contact:
- Antonio Linares
- Site Admin
- Posts: 42450
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 20 times
- Been thanked: 58 times
- Contact:
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
Thanks,
I added the following lines
on runtime I get
Unrecoverable error 9023:
hb_xgrab requested to allocate zero bytes
Did I forget something ?
I added the following lines
Code: Select all | Expand
char* pText;
......
pText = HB_FUN_WIDETOANSI (pAdapterInfo->Description);
hb_arraySet(pSubArray, 1, hb_itemPutC(pItem, pText));
hb_xfree (pText);
on runtime I get
Unrecoverable error 9023:
hb_xgrab requested to allocate zero bytes
Did I forget something ?
kind regards
Stefan
Stefan
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
Dear Antonio,
Ok, finally I got it.
It depends on the version of iphlpapi.dll and the lib built from it. If I link this lib with my app it runs only on those pc´s with the same version of iphlpapi.dll the lib was build from. If I load the dll dynamically everything works fine on every tested pc.
Maybe the addresses of the functions in the dll differs from one version to another.
Antonio, did you test the function GetNetCardID() against this scenario ? I found this function does not cause an error, but it returns a wrong mac and does not find all nics.
Many thanks for your great support
StefanHaupt wrote:It seems to depend on the pc the app is compiled. Compiling it with my office pc (XP64) it only runs on this pc, on others it crashes without error log, only a system message that there is a problem with he app.
Ok, finally I got it.
It depends on the version of iphlpapi.dll and the lib built from it. If I link this lib with my app it runs only on those pc´s with the same version of iphlpapi.dll the lib was build from. If I load the dll dynamically everything works fine on every tested pc.
Maybe the addresses of the functions in the dll differs from one version to another.
Antonio, did you test the function GetNetCardID() against this scenario ? I found this function does not cause an error, but it returns a wrong mac and does not find all nics.
Many thanks for your great support
kind regards
Stefan
Stefan
- Antonio Linares
- Site Admin
- Posts: 42450
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 20 times
- Been thanked: 58 times
- Contact:
- Antonio Linares
- Site Admin
- Posts: 42450
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 20 times
- Been thanked: 58 times
- Contact:
Stefan,
>
Maybe the addresses of the functions in the dll differs from one version to another.
>
Yes, thats possible. In those cases, the address of the used function should be obtained using GetProcAddress():
http://msdn.microsoft.com/en-us/library/ms683212(VS.85).aspx
There are many examples in these forums using GetProcAddress().
>
did you test the function GetNetCardID() against this scenario ? I found this function does not cause an error, but it returns a wrong mac and does not find all nics.
>
FWH GETNETCARDID() is working fine on Vista (just uses Windows API GetAdaptersInfo(). Though Microsoft recommends to use GetAdaptersAddresses(), GetAdaptersInfo() seems ok for us):
http://msdn.microsoft.com/en-us/library/aa365917.aspx
>
Maybe the addresses of the functions in the dll differs from one version to another.
>
Yes, thats possible. In those cases, the address of the used function should be obtained using GetProcAddress():
http://msdn.microsoft.com/en-us/library/ms683212(VS.85).aspx
There are many examples in these forums using GetProcAddress().
>
did you test the function GetNetCardID() against this scenario ? I found this function does not cause an error, but it returns a wrong mac and does not find all nics.
>
FWH GETNETCARDID() is working fine on Vista (just uses Windows API GetAdaptersInfo(). Though Microsoft recommends to use GetAdaptersAddresses(), GetAdaptersInfo() seems ok for us):
http://msdn.microsoft.com/en-us/library/aa365917.aspx