| View previous topic :: View next topic |
| Author |
Message |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Fri Aug 22, 2003 4:04 pm Post subject: File Handle |
|
|
How can I obtain the handle of a file?  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Fri Aug 22, 2003 5:42 pm Post subject: |
|
|
If I may know why ?
It's possible I think. You should be using an API to open it.
Want to share/restrict write privileges ? security related ?  _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Fri Aug 22, 2003 6:06 pm Post subject: |
|
|
You can use createFileA or W (Wide character)
| Quote: | The CreateFile function creates, opens, or truncates a file, pipe, communications resource, disk device, or console. It returns a handle that can be used to access the object. It can also open and return a handle to a directory.
HANDLE CreateFile(
LPCTSTR lpFileName, // address of name of the file
DWORD dwDesiredAccess, // access (read-write) mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // address of security descriptor
DWORD dwCreationDistribution, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile // handle of file with attributes to copy
);
Parameters
lpFileName
Points to a null-terminated string that specifies the name of the file, pipe, communications resource, disk device, or console to create, open, or truncate.
If *lpFileName is a path, there is a default string size limit of MAX_PATH characters. This limit is related to how the CreateFile function parses paths.
Windows NT: You can transcend this limit and send in paths longer than MAX_PATH characters by calling the wide (W) version of CreateFile and prepending "\\?\" to the path. The "\\?\" tells the function to turn off path parsing. This lets you use paths that are nearly 32k Unicode characters long. You must use fully-qualified paths with this technique. This also works with UNC names. The "\\?\" is ignored as part of the path. For example, "\\?\C:\myworld\private" is seen as "C:\myworld\private", and "\\?\UNC\tom_1\hotstuff\coolapps" is seen as "\\tom_1\hotstuff\coolapps".
dwDesiredAccess
Specifies the type of access to the file or other object. An application can obtain read access, write access, read-write access, or device query access. You can use the following flag constants to build a value for this parameter. Both GENERIC_READ and GENERIC_WRITE must be set to obtain read-write access: |
_________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Aug 22, 2003 6:47 pm Post subject: |
|
|
Hi All,
I think you should use CreateFileA. VDS strings are Ascii strings so you may not want to use CreateFileW unless you are going to also use MultiBytetoWideChar and WideChartoMultiByte. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Fri Aug 22, 2003 11:55 pm Post subject: |
|
|
I wanted to try to make an example with the LockFile and UnlockFile
API functions.
Thanks I'll take a look at your suggestions.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
|