The functions in the File category monitor and close the file, device, and pipe resources that are open on a server.
|
Function |
Description |
|
Forces a resource closed. |
|
|
This function is the same as NetFileClose2 except that it is RPC-based. |
|
|
Lists all resources open on a server. |
|
|
This function is the same as NetFileEnum2 except that it uses 32-bit data structures, is RPC-based, and is resumable. |
|
|
Retrieves information about an opening of a server resource. |
|
|
This function is the same as NetFileGetInfo2 except that it uses 32-bit data structures and is RPC-based. |
NetFileClose2 and NetFileClose32 force a server resource closed. These functions can be used when a system error prevents normal closure (for example, when the DosClose function fails).
NetFileEnum2 and NetFileEnum32 return information about resources open on a server. A file can be opened one or more times by one or more applications. Each file opening is uniquely identified. NetFileEnum2 and NetFileEnum32 return an entry for all file openings.
NetFileGetInfo2 and NetFileGetInfo32 return information about one particular opening of a resource.
NetFileEnum2, NetFileEnum32, NetFileGetInfo2, and NetFileGetInfo32 can return the file identifier only or the file identifier and additional detailed data.
Four levels and data structures are available. Levels 0 and 1 return short file identifiers. Levels 2 and 3 return long file identifiers. Long file identifiers support file identifiers greater than 65,536. Levels 0 and 2 return only the identification number that was assigned to the resource when it was opened. Levels 1 and 3 return the identification number, permissions, file locks, and the name of the user who opened the resource.
You should use levels 2 and 3 to ensure that data is returned for all open resources. Levels 0 and 1 are provided only for compatibility with previous LAN Manager releases.
NetFileEnum2 and NetFileGetInfo2 can return level 0 and level 1 data only for those resources that have file identifier values less than 65,536. You should not make assumptions about file identifiers; an open resource can have an identifier greater than 65,536 even if it is the only open resource.
Levels 0 and 1 do not guarantee the return of all valid data. When level 0 or 1 is used, the value of the TotalRemaining parameter returned by NetFileEnum2 also reflects only the number of open files that have file identifier values less than 65,536.
NetFileEnum32 and NetFileGetInfo32 do not support levels 0 and 1.
The NetFileEnum2 and NetFileGetInfo2 functions return data at levels 0, 1, 2, or 3.
The NetFileEnum32 and NetFileGetInfo32 functions return data at levels 2 or 3 only.
These functions return data structures as follows.
The file_info_0 structure has the following format:
struct file_info_0 {
unsigned short fi0_id;
};
fi0_id is the identification number assigned to the resource at opening.
The file_info_1 structure has the following format:
struct file_info_1 {
unsigned short fi1_id;
unsigned short fi1_permissions;
unsigned short fi1_num_locks;
char * fi1_pathname;
char * fi1_username;
};
Within this structure, the parameters are defined as follows:
fi1_id is the identification number assigned to the resource at opening.
fi1_permissions lists the opening applications access permissions.
The bit mask of fi1_permissions is defined in the shares.h file:
|
Manifest |
Bit Mask |
Meaning |
|
FILE_READ |
0x1 |
Permission to read a resource, and by default, execute the resource. |
|
FILE_WRITE |
0x2 |
Permission to write to a resource. |
|
FILE_CREATE |
0x4 |
Permission to create a resource; data may be written when creating it. |
fi1_num_locks tells how many file-locks are on the file, device, or pipe.
fi1_pathname points to an ASCIIZ string giving the path name of the opened resource.
fil_username points to a string telling which user opened the resource.
The file_info_2 data structure that can be returned by NetFileEnum2 and NetFileGetInfo2 has the following format:
struct file_info_2 {
unsigned long fi2_id;
};
Within this structure, fi2_id specifies the identification number assigned to the resource when it is opened.
The 32-bit data structure FILE_INFO_2 that can be returned by NetFileEnum32 and NetFileGetInfo32 has the following format:
typedef struct _FILE_INFO_2 {
DWORD fi2_id;
} FILE_INFO_2, *PFILE_INFO_2, *LPFILE_INFO_2;
Within this structure, the parameters are defined in the same way as in the file_info_2 structure.
The file_info_3 data structure has the following format:
struct file_info_3 {
unsigned long fi3_id;
unsigned short fi3_permissions;
unsigned short fi3_num_locks;
char * fi3_pathname;
char * fi3_username;
};
Within this structure, the parameters are defined as follows:
fi3_id specifies the identification number assigned to the resource when it is opened.
fi3_permissions specifies the access permissions of the opening application. The bit mask of fi3_permissions is defined in the shares.h header file as follows:
|
Code |
Bit Mask |
Meaning |
|
PERM_FILE_READ |
0x1 |
Permission to read a resource and, by default, execute the resource. |
|
PERM_FILE_WRITE |
0x2 |
Permission to write to a resource. |
|
PERM_FILE_CREATE |
0x4 |
Permission to create a resource; data can be written when creating the resource. |
fi3_num_locks tells how many file locks are on the file, device, or pipe.
fi3_pathname points to an ASCIIZ string that gives the path name of the opened resource.
fi3_username points to an ASCIIZ string that specifies which user opened the resource.
The 32-bit data structure FILE_INFO_3 that can be returned by NetFileEnum32 and NetFileGetInfo32 has the following format:
typedef struct _FILE_INFO_3 {
DWORD fi3_id;
DWORD fi3_permissions;
DWORD fi3_num_locks;
LPTSTR fi3_pathname;
LPTSTR fi3_username;
} FILE_INF0_3, *PFILE_INFO3, *LPFILE_INFO_3;
Within this structure, the parameters are defined in the same way as in the file_info_3 structure.