Information générale
Catégorie:
Fonctions Windows API
First: thanks form help
Second:
>Declare integer WNetAddConnection in WIN32API string,string,string
>drive_letter = "G:"
>Machine_name = "\\boss500\"
>The format of a share is \\MachineName\ShareName - you've omitted the >sharename, so the WNetAddConnection() will inherently fail. You need to >specify both parts of the UNC.
I send MachineName and Drive_letter to the WNetAdConnection()
and somthing I dont understand happens: Look
NetWork type: Peer-to-Peer (TCP/IP)
The system must work with Office(.DOC, .XLS ) and those files are in stored in different computers, 1 computer is Win2K Pro, 2 computers Win98/95
I'm triying to create a connection every time my application starts
To be sure the application is working with the network.
So I try to get the network driver mapping and if the station is
not connected, make the connection.
Got 2 problems:
1) Using WScript, in Win2K pro
Sometimes this sequence returns 0, even if the network is connected
ONET = CREATEOBJECT("WScript.Network")
oNetDrives = ONET.EnumNetworkDrives
x = oNetDrives.COUNT
? x && Return's 0, why if I open Explorer I see the drives from other Stations.
* shouldnt EnumNetworkDrives return the current network drive mappings ??
* Also don't get the CD player from each Station
2)
DECLARE INTEGER WNetAddConnection IN WIN32API STRING,STRING,STRING
ONET = CREATEOBJECT("WScript.Network")
oNetDrives = ONET.EnumNetworkDrives
FOR lni = 0 TO oNetDrives.COUNT - 1
? oNetDrives.ITEM(lni) && Displays the drive mapping
* this return's those stings from each computer:
* "\\BOSS700\C" FROM COMPUTER 1
* "\\BOSS300\G" FROM COMPUTER 3
* "\\BOSS500\E" FROM COMPUTER 2
* "\\BOSS500\F" FROM COMPUTER 2
* "\\BOSS300\I" FROM COMPUTER 2
* "\\BOSS700\C" FROM COMPUTER 3
net_drive = oNetDrives.ITEM(lni)
IF NOT EMPTY(net_drive)
Machine_name = SUBSTR(net_drive,1, AT("\",net_drive,3))
DriveLetter = SUBSTR(net_drive,AT("\",net_drive,3)+ 1,1) + ":"
z=WNetAddConnection(Machine_name, "", DriveLetter)
?z
ENDIF
NEXT
****
In computer 1 (win 98)
z returns 85 -> the device is alredy connected.
In computer 3 (win 95)
z returns 85 -> the device is alredy connected.
In computer 2 (win 2K Pro)
z returns 67 -> the remote name is not valid or cannot be located
If I go to the Win2K computer (2), open explorer
I can get Drives from the other Stations (1 & 3)
What im doing wrong here, because Win2k allways returns error 67
Exist a better way to get the information e create the connection ??
Thanks in Advance
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement