Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

Network Stuff

Hi i was wondering,

Is it possilbe with delphi to see witch users are logged in to a station ? (like ms's netwatcher) and how could i disconnect them ? and the last question =) how do i set access rights on directory's ?

Thanx !

Regards, Arijan
0
aluiken
Asked:
aluiken
  • 2
1 Solution
 
Arjan092097Commented:
Yes, that's possible! There's only one problem: Delphi does provide a wrapper for the API functions you need (The svrapi.dll in Windows95 and netapi32.dll in WindowsNT).

The functions you need are:

NetShareEnum: enumerates all the shares you've got
NetSessionEnum: enumerates all the (network)-sessions
NetFileEnum: enumerates open files (via network!)

When you use these API functions you will be able to make a program like MS Netwatcher. An example of a Netwatcher source for WindowsNT is available at the Microsoft MSDN homepage.

Disconnecting users works as follows:
NetSessionDel: disconnect the user using that session

I don't know how to set access rights, but I assume there are some functions in the NetApi32.dll like:
NetAccessEnum
NetAccessAdd etc.

I hope this will help.

Arjan
0
 
aluikenAuthor Commented:
Do you have a sample source for that (win95?)

Regards, Arijan
0
 
Arjan092097Commented:
No, I don't have some sample code. But I think the following will work:

Example for NetShareEnum:
declare NetShareEnum to be external from svrapi.dll

function NetShareEnum(
    LPTSTR servername,      (pointer to string (PChar))
    DWORD level,      
    LPBYTE * bufptr,      (pointer to byte)
    DWORD prefmaxlen,      
    LPDWORD entriesread,(pointer to word)      
    LPDWORD totalentries,      ""
    LPDWORD resume_handle  ):NetApiStatus; external svrapi.dll;

You've to provide a mapping between the types used in Windows API and the ones used by Delphi.

Then it's possible to use the function. To find a description of the function and his parameters you can look in the helpfiles.

Succes,

Arjan
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now