wNetGetConnection() issue

wNetGetConnection() issue

Postby peterk » 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
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Fri Apr 20, 2007 3:39 pm

should iLen be DWORD ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10622
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Fri Apr 20, 2007 8:09 pm

lLen is an unsigned long wich it is like a DWORD
Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10622
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Fri Apr 20, 2007 11:24 pm

NageswaraRao,

You are welcome :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: cmsoft, Natter and 53 guests