
Networking programming querry (SHARES)
Although which programming language you want to use is a part of personal
preference, I can tell you how to accomplish the task in hand.
Windows API has a powerful set of functioins which can do the job. The API
call WNetEnumResource is the function you should be using. This function, if
properly used, can list the shares and their types (i.e. File, Printer etc )
on the entire network. I once wrote a function which will call itself
recursively and log the resources of the entire network. The whole function
did take lot of time to run since it used to query the entire network with
all its domains and sub-domains. This is because of the way the function was
written. With very little effort (read setting NETRESOURCE structure
properly and then calling WNetOpenEnum and WNetEnumResource APIs) you can
obtain only the chunk of the information you need. If using VB, you can
create a class which will query and return only the chunk of information.
This class can have a method which will start the internal timer and return
immediately. The actual querying is started when the timer fires. All the
objects of this class will also have a reference to one global object which
will store the results (who said this was bad programming practice ?...).
You are warned:
1. As the number of timers increase, the system might come down to its
knees.
2. You may run into global re-entrency problems and might have to write code
(using CRITICAL SECTIONS, MUTEXEX, Semaphores .... you got the idea ) to
avoid problems when multiple objects try to update the global resource.
3. For real multi-threading you may try to use CreateThread API in VB which
can be more problem ( I know they say NEVER use this API in VB, but thats
for faint hearts..) but you can overcome it, after all you are a programmer.
You can use Java ( read VJ++ ) to take advantage of inbuilt threading and
JDirect with VJ++ to use Windows APIs. If you have time, go for C/C++/VC++.
I hope that helps.
Jalil
P.S. I prefer replying to news groups as it may help others having same
problems.
Quote:
>Networking programming querry (SHARES)
>Quick version of the question:
>How do I view a list of shares on a remote machine & which programming
>language should I use to write code to do this?
>Is there a way to mulithread this querry? (ask for shares from several
>machines at once, because of transaction time, threading it would increase
>productivity of the application)
>More detailed: I'm wanting to make an application that can view the shares
>from a windows/mac/linux/unix box, I need to know which language I should
>start writing this code/script in, either Java, VB, or C++ (POSSIBLY perl,
>but I'm reluctant to start perl) my prefered language is VB.
>to understand what it is I'm doing, there's an application in windows that
>is similar to this, however it only does 1 machine at a time, and is slow
>even at that. in DOS run the net command, you need to include the ip
>address of the computer you're trying to get shares from:
>net view \\10.0.0.0.1
>RESULTS:
>Shared resources at \\128.95.39.142
>Sharename Type Comment
>============================
>C Disk
>D Disk
>E Disk
>SOUNDS Disk
>HP PRINTER
>The command was completed successfully.