LLamada a WNetGetConnectionA no me funciona

LLamada a WNetGetConnectionA no me funciona

Postby Carlos Mora » Thu Oct 13, 2005 9: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
Code: Select all  Expand view
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
Code: Select all  Expand view
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

Code: Select all  Expand view
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:
Code: Select all  Expand view
//
// 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
Carlos Mora
 

Postby Antonio Linares » Thu Oct 20, 2005 4:01 pm

Carlos,

Pruébalo así:

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41436
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 36 guests