mapping server volumes

mapping server volumes

Postby MarcoBoschi » Wed Nov 19, 2008 4:27 pm

Hi,
In this way I am able to connect to a server volume within a fivewin application.

WinExec( "net use \\server\volume /user:Administrator marco ", 1)

...
...
...
...


WinExec( "net use \\server\volume /DELETE", 1)

But I don't like that!
Are there any other ways :idea: to do the same thing? Functions, Classes?

Thanks in advance
Marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Postby MGA » Wed Nov 19, 2008 7:26 pm

ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1252
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Postby StefanHaupt » Thu Nov 20, 2008 8:46 am

Marco,

try these functions

Code: Select all  Expand view
//--------------------------------------------------------------------------
FUNCTION MapNetworkDrive(cShare, cDevice)
RETURN(WNetAddConnection(cShare,cDevice))

//--------------------------------------------------------------------------

FUNCTION DelNetworkDrive(cDevice)
RETURN(WNetCancelConnection(cDevice,.T.))

//--------------------------------------------------------------------------
#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"
#include "hbvm.h"
#include "hbapiitm.h"

#define MAX_FILE_NAME 1024

HB_FUNC( WNETADDCONNECTION )
{
char cLocal[MAX_FILE_NAME];
BOOL Result = FALSE ;
int nLength ;
    if (ISCHAR(1) && (hb_parclen(1) >5) && ISCHAR(2) )
    {
  nLength= hb_parclen(2) ;
  if ((nLength>=2) && (nLength< MAX_PATH-1) )
  {
   memcpy(cLocal, hb_parc(2), 2) ;
   cLocal[2]= '\0';
   Result = ( WNetAddConnection(hb_parc(1),NULL,cLocal) == NO_ERROR) ;
  }
}
hb_retl(Result) ;
}

HB_FUNC( WNETCANCELCONNECTION )
{
char cLocal[3];
BOOL Result = FALSE ;
if (ISCHAR(1) && (hb_parclen(1) >= 2))
{
  memcpy(cLocal, hb_parc(1), 2) ;
  cLocal[2]= '\0';
  Result = (WNetCancelConnection(cLocal,ISLOG(2) && hb_parl(2)? TRUE :
FALSE)== NO_ERROR) ;
}
hb_retl(Result) ;
}

#pragma ENDDUMP
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests