FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour LLamada a WNetGetConnectionA no me funciona
Posts: 155
Joined: Tue Dec 30, 2008 03:07 AM
LLamada a WNetGetConnectionA no me funciona
Posted: Thu Oct 13, 2005 09:49 AM
Amigos,
no se que estoy haciendo mal, a ver si alguien me dice donde meto la pata.
Quiero saber el nombre de red de un disco. Para eso esta la funcion WNetGetConnectionA en mpr.dll
La declaracion segun los manuales de la API son
Private Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long

por lo que la declaro en mi prg de HArbour + FW
dll32 static function ;
      WNetGetCon( @cLocalName AS STRING, @cRemoteName AS STRING, nLength AS LONG ) ;
      AS LONG PASCAL FROM "WNetGetConnectionA" ;
      Lib "mpr.dll"


Y luego la llamo

function GetNetDriveName( cDrive )
local x := 0
local cName := Space( 128 )

cDrive := Left( cDrive, 3 )+Chr(0)
x:= WNetGetCon( @cDrive, @cName, 128 )
debug x, cDrive, Len(cname)
If x != 0
   cDrive := Left( cDrive, 2 )+Chr(0)
   x:= WNetGetCon( @cDrive, @cName, 128 )
   debug x, cDrive, Len(cname)
   If x != 0
      cDrive := Left( cDrive, 1 )+Chr(0)
      x:= WNetGetCon( @cDrive, @cName, 128 )
      debug x, cDrive, Len(cname)
   EndIf
EndIf


Asi, a lo bruto, porque me falla!
el comando debug me hace un Outputdebugstring de cada parametro en el dbwin
x siempre me trae el codigo de error 487
que en winerror.h dice:
//
// MessageId: ERROR_INVALID_ADDRESS
//
// MessageText:
//
//  Attempt to access invalid address.
//
#define ERROR_INVALID_ADDRESS            487L


Es decir que hay algun problma con la declaracion o el pase de parametros o algo, pero no me doy cuenta.

Alguna idea?

Saludos
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
LLamada a WNetGetConnectionA no me funciona
Posted: Thu Oct 20, 2005 04:01 PM
Carlos,

Pruébalo así:

dll32 static function ; 
      WNetGetCon( cLocalName AS STRING, cRemoteName AS STRING, nLength AS LONG ) ; 
      AS LONG PASCAL FROM "WNetGetConnectionA" ; 
      Lib "mpr.dll"
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion