Link to home
Start Free TrialLog in
Avatar of PLC
PLC

asked on

Users on a shared resource

I want to find out who is using a shared resource on my Windows95 machine.
Something similar to the net watcher application delivered with Windows 95.
This seams to be a lot easier with NT than on win95.
Anybody know how I can find out which user is using which files on a shared resource?
Tnx
Avatar of Madshi
Madshi

Perhaps NetFileEnum helps? But watch out - like all net APIs this API has different parameters under win9x than it has under winNT. Normally you find only the parameters for winNT. Look in the "svrapi.h" for the win9x headers.

Regards, Madshi.
Avatar of PLC

ASKER

Netfileenum is definitely the api that I need. Only trouble is that by now I got plenty of comments, info, examples from all kinds of sources on how to use and on NT it works fine, on win95 all I get is error 87.
Is there anybody who has ever done this on win95?
Not yet. At least not this API. But if your show me your sources (please not too long... :-), I'll find a bug perhaps.
BTW: 87 is ERROR_INVALID_PARAMETER...
Avatar of PLC

ASKER

Oops seem to have deleted that code, probably in frustration :-); but this gave the same problem, so probably the same error.
tnx

Function NetSessionEnum(ServerName:PWideChar;UNCCLientName:PWideChar;
                        Usernaam:PWideChar;Level:DWord;lpInfo:Pointer;
                        Maxlen:DWORD;EntriesRead:PDWORD;Totalentries:PDWord;
                        hEnum:PDWord):DWORD stdcall;
function NetSessionEnum; external 'svrapi.dll' name 'NetSessionEnum';

procedure TForm1.Button2Click(Sender: TObject);
var hEnum:PDWord;
    Result:Integer;
    NetRes:PInfo;
    NetResult:Array[0..200] of SESSION_INFO_10;
    maxlen:DWord;
    entriesread,totalentries:PDword;
begin
maxlen:=1000; Entriesread:=0;Totalentries:=0;    
NetRes:=Addr(NetResult);
Result:=0;
While Result=0 do
begin
 Result:=NetSessionEnum(nil,
                       nil,
                       nil,
                       10,
                       Netres,
                       Maxlen,
                       EntriesRead,
                       Totalentries,
                       hEnum);
 if Result=0
    then listbox1.Items.Add(NetResult[0].lpUser)
end;
end;
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PLC

ASKER

Quite, somebody gave me the wrong declarations to work from. Checked the file now myself, stupid me.
I'll try this now. Anyway, for bearing with me I think you deserve to get the points.
tnx
Patrick