Home > Archive > Visual Basic > August 2005 > need very simple LAN manager/detector
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
need very simple LAN manager/detector
|
|
|
| looking for a very simple network type manager, which can detect all PC's
connected in a LAN/Workgroup.....send a message to them, copy a file to each
one; need with vb6 source code. Any suggestions?
| |
|
| Will this work?
http://freevbcode.com/ShowCode.Asp?ID=5182
"pb" <pb@discussions.microsoft.com> wrote in message
news:4840155A-450F-4A37-8B79-32B8ACB18BA1@microsoft.com...
> looking for a very simple network type manager, which can detect all PC's
> connected in a LAN/Workgroup.....send a message to them, copy a file to
> each
> one; need with vb6 source code. Any suggestions?
| |
|
| Thanks anyway....but it crashed my pc and i could not send anything to other
IPs.....let me know if you have anything else....thanks.
"UGH" wrote:
> Will this work?
>
> http://freevbcode.com/ShowCode.Asp?ID=5182
>
>
>
> "pb" <pb@discussions.microsoft.com> wrote in message
> news:4840155A-450F-4A37-8B79-32B8ACB18BA1@microsoft.com...
>
>
>
| |
|
| >which can detect all PC's
>connected in a LAN/Workgroup
The sample is very slow, just as slow as when Windows
tries to show all Network computers.
List shares is much faster.
>send a message to them, copy a file to each
> one; need with vb6 source code
Where do you want to copy the file in the computer ?
Does the network computer have Share permission to do so ?
You can't copy the file unless you have permission.
"pb" <pb@discussions.microsoft.com> wrote in message
news:4840155A-450F-4A37-8B79-32B8ACB18BA1@microsoft.com...
> looking for a very simple network type manager, which can detect all PC's
> connected in a LAN/Workgroup.....send a message to them, copy a file to
> each
> one; need with vb6 source code. Any suggestions?
| |
|
| thanks for responding. I've built a customer management program which i want
to run on a network. I'm not sending a file actually.....i just thought that
would be the best way to do it. Each pc has my appliation installed and it
reads that file, so it can make the necessary changes. However, i could just
pass the change from 1 pc to another. When one pc changes a certain value on
a customer record....all the other pc customer record are changed
respectively.. Is this possilbe? I'm looking into winsock at the
moment....but still researching the syntax.
"Ted" wrote:
>
> The sample is very slow, just as slow as when Windows
> tries to show all Network computers.
> List shares is much faster.
>
>
> Where do you want to copy the file in the computer ?
> Does the network computer have Share permission to do so ?
> You can't copy the file unless you have permission.
>
>
>
>
>
> "pb" <pb@discussions.microsoft.com> wrote in message
> news:4840155A-450F-4A37-8B79-32B8ACB18BA1@microsoft.com...
>
>
>
| |
|
|
Maybe better some body else can help you updating customer records.
Below gets computer names in a LAN:
In Form code:
Private Sub Command1_Click()
NetEnumLocal
Dim i
For i = 1 To UBound(NI)
List1.AddItem NI(i).RemoteName
Next i
End Sub
Module code:
Option Explicit
Private Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As Long
lpRemoteName As Long
lpComment As Long
lpProvider As Long
End Type
Private Type NETRESOURCE_STRING
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As String
lpRemoteName As String
lpComment As String
lpProvider As String
End Type
Type NetInfo 'UDT to store Data and use it for
dwScope As Long 'filling ListView
dwType As Long
dwDisplayType As Long
dwUsage As Long
LocalName As String
RemoteName As String
Comment As String
Provider As String
End Type
Private Declare Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA"
(ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage As Long,
lpNetResource As Any, lphEnum As Long) As Long
Private Declare Function WNetEnumResource Lib "mpr.dll" Alias
"WNetEnumResourceA" (ByVal hEnum As Long, lpcCount As Long, ByVal lpBuffer
As Long, lpBufferSize As Long) As Long
Private Declare Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Long)
As Long
Const RESOURCE_CONNECTED = &H1
Const RESOURCE_GLOBALNET = &H2
Const RESOURCE_REMEMBERED = &H3
Const RESOURCE_RECENT = &H4
Const RESOURCE_CONTEXT = &H5
Public Const RESOURCETYPE_ANY = &H0
Public Const RESOURCETYPE_DISK = &H1
Public Const RESOURCETYPE_PRINT = &H2
Public Const RESOURCETYPE_RESERVED = &H8
Public Const RESOURCETYPE_UNKNOWN = &HFFFF
Public Const RESOURCEUSAGE_CONNECTABLE = &H1
Public Const RESOURCEUSAGE_CONTAINER = &H2
Public Const RESOURCEUSAGE_NOLOCALDEVICE = &H4
Public Const RESOURCEUSAGE_SIBLING = &H8
Public Const RESOURCEUSAGE_ALL = RESOURCEUSAGE_CONNECTABLE Or
RESOURCEUSAGE_CONTAINER
Public Const RESOURCEUSAGE_RESERVED = &H80000000
Public Const RESOURCEDISPLAYTYPE_GENERIC = &H0
Public Const RESOURCEDISPLAYTYPE_DOMAIN = &H1
Public Const RESOURCEDISPLAYTYPE_SERVER = &H2
Public Const RESOURCEDISPLAYTYPE_SHARE = &H3
Public Const RESOURCEDISPLAYTYPE_FILE = &H4
Public Const RESOURCEDISPLAYTYPE_GROUP = &H5
Public Const RESOURCEDISPLAYTYPE_NETWORK = &H6
Public Const RESOURCEDISPLAYTYPE_ROOT = &H7
Public Const RESOURCEDISPLAYTYPE_SHAREADMIN = &H8
Public Const RESOURCEDISPLAYTYPE_DIRECTORY = &H9
Public Const RESOURCEDISPLAYTYPE_TREE = &HA
Public Const GMEM_FIXED = &H0
Public Const GMEM_ZEROINIT = &H40
Public Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT)
Public Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long,
ByVal dwBytes As Long) As Long
Public Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As
Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
(Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function CopyPointer2String Lib "kernel32" Alias "lstrcpyA"
(ByVal NewString As String, ByVal OldString As Long) As Long
Public NI() As NetInfo
Public NetCount As Long
Public NR As NETRESOURCE
Public NRS As NETRESOURCE_STRING
Public ShareName As String
Public Function PointerToString(p As Long) As String
Dim s As String
s = String(255, Chr$(0))
CopyPointer2String s, p
PointerToString = Left(s, InStr(s, Chr$(0)) - 1)
End Function
Private Function GetPointerToString(lpString As Long, nBytes As Long) As
String
Dim Buffer As String
If nBytes Then
Buffer = Space$(nBytes)
CopyMemory ByVal Buffer, ByVal lpString, nBytes
GetPointerToString = Buffer
End If
End Function
Private Sub FillNRS(Index As Long)
NRS.dwDisplayType = NI(Index).dwDisplayType
NRS.dwScope = NI(Index).dwScope
NRS.dwType = NI(Index).dwType
NRS.dwUsage = NI(Index).dwUsage
NRS.lpComment = NI(Index).Comment & Chr$(0)
NRS.lpLocalName = NI(Index).LocalName & Chr$(0)
NRS.lpProvider = NI(Index).Provider & Chr$(0)
NRS.lpRemoteName = NI(Index).RemoteName & Chr$(0)
End Sub
Private Sub ClearNr()
NR.dwDisplayType = 0&
NR.dwScope = 0&
NR.dwType = 0&
NR.dwUsage = 0&
NR.lpComment = 0&
NR.lpLocalName = 0&
NR.lpProvider = 0&
NR.lpRemoteName = 0&
End Sub
Private Sub ClearNrs()
NRS.dwDisplayType = 0&
NRS.dwScope = 0&
NRS.dwType = 0&
NRS.dwUsage = 0&
NRS.lpComment = Chr$(0)
NRS.lpLocalName = Chr$(0)
NRS.lpProvider = Chr$(0)
NRS.lpRemoteName = Chr$(0)
End Sub
Private Sub FillInfo(Index As Long)
NI(Index).dwScope = NR.dwScope
NI(Index).dwDisplayType = NR.dwDisplayType
NI(Index).dwType = NR.dwType
NI(Index).dwUsage = NR.dwUsage
NI(Index).RemoteName = PointerToString(NR.lpRemoteName)
NI(Index).LocalName = PointerToString(NR.lpLocalName)
NI(Index).Comment = PointerToString(NR.lpComment)
NI(Index).Provider = PointerToString(NR.lpProvider)
End Sub
Public Function NetEnumChild(sRN As String) As Long
Dim hEnum As Long, lpBuff As Long
Dim cbBuff As Long, cCount As Long
Dim p As Long, res As Long, i As Long
On Error GoTo ErrorHandler
NRS.lpRemoteName = sRN & Chr$(0)
cbBuff = 16384
cCount = &HFFFFFFFF
res = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY,
RESOURCEUSAGE_CONTAINER, NRS, hEnum)
'If no error ocuured, res = 0, else ret > 0
'If you need, you can handle more errors
If res = 67 Then MsgBox "Sorry, this domain is not availiable now",
vbExclamation, "Network Error"
If res = 1244 Then MsgBox "Password reguired", vbExclamation, "Network
Error"
If res = 0 Then
lpBuff = GlobalAlloc(GPTR, cbBuff)
res = WNetEnumResource(hEnum, cCount, lpBuff, cbBuff)
If res = 0 Then
ReDim NI(cCount)
p = lpBuff
For i = 1 To cCount
CopyMemory NR, ByVal p, LenB(NR)
FillInfo i
p = p + LenB(NR)
Next i
End If
ErrorHandler:
On Error Resume Next
If lpBuff <> 0 Then GlobalFree (lpBuff)
WNetCloseEnum (hEnum)
End If
NetEnumChild = cCount
End Function
Public Sub NetEnumLocal()
'This function enums neighborhood
Dim hEnum As Long, lpBuff As Long
Dim cbBuff As Long, cCount As Long
Dim p As Long, res As Long, i As Long
On Error GoTo ErrorHandler
ClearNr
cbBuff = 16384
cCount = &HFFFFFFFF
res = WNetOpenEnum(RESOURCE_CONTEXT, RESOURCETYPE_ANY,
RESOURCEUSAGE_CONTAINER, NR, hEnum)
If res = 0 Then
lpBuff = GlobalAlloc(GPTR, cbBuff)
res = WNetEnumResource(hEnum, cCount, lpBuff, cbBuff)
If res = 0 Then
ReDim NI(cCount)
p = lpBuff
For i = 1 To cCount
CopyMemory NR, ByVal p, LenB(NR)
FillInfo i
p = p + LenB(NR)
Next i
End If
ErrorHandler:
On Error Resume Next
If lpBuff <> 0 Then GlobalFree (lpBuff)
WNetCloseEnum (hEnum)
End If
End Sub
| |
|
| >When one pc changes a certain value on
>a customer record
Let us say one computer was down, so customer
records didn't get updated on that computer,
where would it get latest customer record list ?
Maybe it is better to have one computer act
as a server and each computer get customer record
from the server. Only the server updates customer
reports.
Are you going to use database or some grid control
to save customer records ?
"pb" <pb@discussions.microsoft.com> wrote in message
news:55886DFC-0E8B-4D73-BDBE-9BBC0538D908@microsoft.com...[color=darkred]
> thanks for responding. I've built a customer management program which i
> want
> to run on a network. I'm not sending a file actually.....i just thought
> that
> would be the best way to do it. Each pc has my appliation installed and
> it
> reads that file, so it can make the necessary changes. However, i could
> just
> pass the change from 1 pc to another. When one pc changes a certain value
> on
> a customer record....all the other pc customer record are changed
> respectively.. Is this possilbe? I'm looking into winsock at the
> moment....but still researching the syntax.
>
> "Ted" wrote:
>
| |
|
| i was thinking when my application starts up, it does a sync with the
database and then utilizes the network control until they shut it down again.
The database is an MS access db and it will lie on a shared drive on 1 pc in
the network which everyone can map to. The location of the database is hard
set in my programs settings menu. Thanks for the code. I'll give it a go.
"Ted" wrote:
>
> Let us say one computer was down, so customer
> records didn't get updated on that computer,
> where would it get latest customer record list ?
> Maybe it is better to have one computer act
> as a server and each computer get customer record
> from the server. Only the server updates customer
> reports.
> Are you going to use database or some grid control
> to save customer records ?
>
>
>
>
> "pb" <pb@discussions.microsoft.com> wrote in message
> news:55886DFC-0E8B-4D73-BDBE-9BBC0538D908@microsoft.com...
>
>
>
| |
|
| can i call a function/sub from 1 pc to another?
| |
|
| There are a few, I never looked into them because
they didn't work in Win 98, plus some are limited to
256 characters.
There is a new sample I found recently but never
used it much, check it out. Doesn't work in Win 98 either.
Most likely limited to number of characters.
http://www.freevbcode.com/ShowCode.Asp?ID=5983
Here is a commercial Activex control that works in
Win 98 to XP, but also limited to 400 characters.
http://www.namtuk.com/winpopupactivex.aspx
Maybe somebody has a better way.
Try post this in a new post.
"pb" <pb@discussions.microsoft.com> wrote in message
news:702E8D5D-9649-4878-A651-B882FB374799@microsoft.com...
> can i call a function/sub from 1 pc to another?
|
|
|
|
|