FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Network only works after selecting drive
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Network only works after selecting drive
Posted: Tue Dec 20, 2011 06:52 AM
Hi,

On a network of a client I want to copy files from one PC to an other.
I check if the path exist with
Code (fw): Select all Collapse
IF file(vNetwerkPath+'\VLD.EXE')


It work very nice, but...
If the client first start the PC, he have to go to the explorer and select the drive before it works. Otherwise is returns False, and I can't copy the files.
The network map is configured that it automatic reconnect after startup.
Does anyone know a solution for this problem?
PS The problem is not only with my program, also other programs need first selecting the drive before it works.

Regards,
Marc
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Network only works after selecting drive
Posted: Tue Dec 20, 2011 08:41 AM

Mark,

This is a very well know Windows-problem.

I have been looking for a solution for many, many years. But unfortunately, I never found one.

What do I tell to my customers ?
I always create a shortcut on the desktop for the mapped drive. And I always tell my customer to doubleclick on this shortcut before doing anything else. If so, he/she is sure that the networkmapping is working fine.

I'm afraid that is the only solution, to my opnion.

Good luck.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Network only works after selecting drive
Posted: Tue Dec 20, 2011 10:26 AM

Michel,

I already told my customer to do this, but she find it to difficult to remember :roll: and she ask me to try to fix it so she doesn't have to select the drive each time after starting the PC :(

Regards,
Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Network only works after selecting drive
Posted: Wed Dec 21, 2011 07:55 AM
Marc,

maybe you can use this code snippet to check the connection

Code (fw): Select all Collapse
//--------------------------------------------------------------------------
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

/*
nRetCode := WNetAddConnection2(  RemoteName, Password, UserName, LocalName )

   if nRetCode <> 0

      if nRetCode = 85
         // alreday connected

      elseif nRetCode = 67
         msginfo( "RemoteName " + RemoteName + CRLF +;
            "Password  " + Password  + CRLF +;
            "UserName  " + UserName  + CRLF +;
            "LocalName " + LocalName + CRLF +;
            CRLF +;
            "System error 67 - The network name cannot be found" )

      elseif nRetCode = 1219
         msginfo( "RemoteName " + RemoteName + CRLF +;
            "Password " + Password + CRLF +;
            "UserName " + UserName + CRLF +;
            "LocalName " + LocalName + CRLF +;
            CRLF +;
            "System error 1219 - Multiple connections to a server" )
      endif

   endif
*/
kind regards

Stefan
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Network only works after selecting drive
Posted: Wed Dec 21, 2011 09:49 AM

Stefan,

Thanks for the code. I will try it and let you know the result.

Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Network only works after selecting drive
Posted: Wed Dec 21, 2011 02:19 PM

Hi,
this problem generally is due to the fact that the user on the windows client is not defined on the server.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Network only works after selecting drive
Posted: Thu Dec 22, 2011 06:01 PM

Stefan,

Your code seems to work. Now they can access the files without selecting the drive!

Thanks,
Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Network only works after selecting drive
Posted: Fri Dec 23, 2011 08:16 AM

:D

kind regards

Stefan
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: Network only works after selecting drive
Posted: Mon Dec 26, 2011 09:23 AM

Hi ,
I use this:

LOCAL cKomanda := ""

cKomanda := "command.com /c "+"NET USE "+sDisk+": "+"\"+ALLTRIM(sPat)+"\"+ALLTRIM(sName)+" /yes"
WinExec(cKomanda,0)

// Your code here

cKomanda := "command.com /c "+"NET USE "+sDisk+": "+"/DELETE /YES"
WinExec(cKomanda,0)

Regards,

Continue the discussion