FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour wNetGetConnection() issue
Posts: 47
Joined: Thu Jul 13, 2006 02:39 PM
wNetGetConnection() issue
Posted: Tue Apr 17, 2007 12:34 PM

Hi Antonio

wNetGetConnection( z: ) returns the correct UNC path for the specified drive but the returned value (which is correct) has a whole lot of garbage chrs appended to it, which I have to remove by finding the first Chr(0) in the returned value and substringing to the chr before that.

Using xHb and fWh version from +- Oct 2006

Regds
Peter

Peter
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
wNetGetConnection() issue
Posted: Thu Apr 19, 2007 12:16 PM

Peter,

Its strange because the C source code uses lLen to trim it:

WNetGetConnection( hb_parc( 1 ), ( char * ) bBuffer, &lLen );

hb_retclen( ( char * ) bBuffer, lLen );

So it looks as a Windows API wrong behavior. But you got a good workaround :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
wNetGetConnection() issue
Posted: Fri Apr 20, 2007 03:39 PM

should iLen be DWORD ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
wNetGetConnection() issue
Posted: Fri Apr 20, 2007 08:09 PM
lLen is an unsigned long wich it is like a DWORD
function Main()

   MsgInfo( Test() )

return nil

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HB_FUNC( TEST )
{
   hb_retl( sizeof( unsigned long ) == sizeof( DWORD ) );
}

#pragma ENDDUMP

It shows .T.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
wNetGetConnection() issue
Posted: Fri Apr 20, 2007 11:00 PM

you are right. sorry. i shdnt have bothered you with that.
actually long time back wnetgetuser() function was having the same problem. I used to have a wrapper function truncating upto chr(0). later it got solved on its own. similar problem exists now with this function.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
wNetGetConnection() issue
Posted: Fri Apr 20, 2007 11:24 PM

NageswaraRao,

You are welcome :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion