Using API function with VC1.52 
Author Message
 Using API function with VC1.52

I am trying to use the API function OpenFile to see if a file exists.
When I use it, I always get the error HFILE_ERROR even if the file is
there or not. It says in the help (VC1.52) that this function returns an
MSDOS file handle. Currently the machine that I am testing on doesn't
have MSDOS on it (Win95 with no MSDOS or NT4).

Could this be a problem? (ie. must be running WFW)

Also, does OpenFile work on Win95 and NT4? It says in VC4 help to use
CreateFile for Win32 instead of OpenFile, but since I am using VC1.52
(must use Win16).

Thanks



Wed, 23 Jun 1999 03:00:00 GMT  
 Using API function with VC1.52

Kyui,
   You might want to post a note about what parameters you're passing to
OpenFile() -- it should work under both Win16 and Win32...



Quote:
> I am trying to use the API function OpenFile to see if a file exists.
> When I use it, I always get the error HFILE_ERROR even if the file is
> there or not. It says in the help (VC1.52) that this function returns an
> MSDOS file handle. Currently the machine that I am testing on doesn't
> have MSDOS on it (Win95 with no MSDOS or NT4).

> Could this be a problem? (ie. must be running WFW)

> Also, does OpenFile work on Win95 and NT4? It says in VC4 help to use
> CreateFile for Win32 instead of OpenFile, but since I am using VC1.52
> (must use Win16).

> Thanks



Wed, 23 Jun 1999 03:00:00 GMT  
 Using API function with VC1.52

Well, the parameters that I use goes something like this:

LPOFSTRUCT  lpReOpenBuff;

if(OpenFile(szFullPathOfFile, lpReOpenBuff,OF_EXIST)==HFILE_ERROR)
{
        handle error

Quote:
}

Does anyone see anything wrong?
Quote:

> Kyui,
>    You might want to post a note about what parameters you're passing to
> OpenFile() -- it should work under both Win16 and Win32...



> > I am trying to use the API function OpenFile to see if a file exists.
> > When I use it, I always get the error HFILE_ERROR even if the file is
> > there or not. It says in the help (VC1.52) that this function returns an
> > MSDOS file handle. Currently the machine that I am testing on doesn't
> > have MSDOS on it (Win95 with no MSDOS or NT4).

> > Could this be a problem? (ie. must be running WFW)

> > Also, does OpenFile work on Win95 and NT4? It says in VC4 help to use
> > CreateFile for Win32 instead of OpenFile, but since I am using VC1.52
> > (must use Win16).

> > Thanks



Thu, 24 Jun 1999 03:00:00 GMT  
 Using API function with VC1.52

Kyui,
  I see two things worth mentioning in your code sample:

1.      Your declaration of 'lpReOpenBuff' declares a pointer to OFSTRUCT.
Then you're passing the pointer to OpenFile.  The problem is that the
pointer hasn't been initialized to point to anything.  What you need to do
is, rather than creating a pointer, create a struct of type OFSTRUCT, as
in:

OFSTRUCT myOpenStruct;

2.      The docs for OFSTRUCT say that you need to initialize the 'cBytes'
member before calling OpenFile(), see below:

myOpenStruct.cBytes = sizeof(OFSTRUCT)

3.      When you call OpenFile(), you'll need to take the address of your
OFSTRUCT

OpenFile(szFullFilePath, &myOpenStruct,OF_EXIST)

4.      Finally, (just to be complete), I suggest you always initialize such
structures to NULL just in case you missed something.  That would make the
completed version look like this:

OFSTRUCT  ReOpenBuff = {sizeof(OFSTRUCT)};

if (OpenFile(szFullPathOfFile, &ReOpenBuff,OF_EXIST)==HFILE_ERROR)
{

Quote:
}



Quote:
> Well, the parameters that I use goes something like this:

> LPOFSTRUCT  lpReOpenBuff;

> if(OpenFile(szFullPathOfFile, lpReOpenBuff,OF_EXIST)==HFILE_ERROR)
> {
>    handle error
> }

> Does anyone see anything wrong?


> > Kyui,
> >    You might want to post a note about what parameters you're passing
to
> > OpenFile() -- it should work under both Win16 and Win32...



> > > I am trying to use the API function OpenFile to see if a file exists.
> > > When I use it, I always get the error HFILE_ERROR even if the file is
> > > there or not. It says in the help (VC1.52) that this function returns
an
> > > MSDOS file handle. Currently the machine that I am testing on doesn't
> > > have MSDOS on it (Win95 with no MSDOS or NT4).

> > > Could this be a problem? (ie. must be running WFW)

> > > Also, does OpenFile work on Win95 and NT4? It says in VC4 help to use
> > > CreateFile for Win32 instead of OpenFile, but since I am using VC1.52
> > > (must use Win16).

> > > Thanks



Thu, 24 Jun 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Tabbing using VC1.52

2. can vc5 typelibs be used in vc1.52?

3. Help: CRecordset using Oracle7 and VC1.52

4. HELP! Whats wrong with this code?VC1.52

5. Help - How to access MS-ACCess from VC1.52

6. Problem with vc1.52, dos window in win95 and graphics program

7. ldllcew.lib - converting VC1.52 to VC5

8. Help porting VC1.52 DLL to VC2.2 DLL

9. VC1.52 and Win95

10. VC1.52 Setup Install Program

11. VC1.52 Compiler optimisation problem

12. VC1.52!!Whats wrong with this??

 

 
Powered by phpBB® Forum Software