Using GetOpenFileName on both Win98 and WinXP
-
GetOpenFileName() is Win32 API function which accepts a pointer to a OPENFILENAME structure. In this structure, you have to set up a member lStructSize to sizeof(OPENFILENAME) for Windows XP and above. But for Windows98 it must be OPENFILENAME_SIZE_VERSION_400. When I use an if statement to do it, compiler gives fatal error and stops :
OPENFILENAME ofn;
if(win98()==FALSE)
ofn.lStructSize = sizeof(OPENFILENAME); //for Windows XP
else
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; //for Windows 98/MEOfcourse I can make seperate functions for opening files in win98 etc. But what is a better way to do this. Thank you
-
GetOpenFileName() is Win32 API function which accepts a pointer to a OPENFILENAME structure. In this structure, you have to set up a member lStructSize to sizeof(OPENFILENAME) for Windows XP and above. But for Windows98 it must be OPENFILENAME_SIZE_VERSION_400. When I use an if statement to do it, compiler gives fatal error and stops :
OPENFILENAME ofn;
if(win98()==FALSE)
ofn.lStructSize = sizeof(OPENFILENAME); //for Windows XP
else
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; //for Windows 98/MEOfcourse I can make seperate functions for opening files in win98 etc. But what is a better way to do this. Thank you
What is the error that you get?
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
What is the error that you get?
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
This is what Pelles C Compiler displays : Building MAIN.obj. C:\Code\Hasher\MAIN.C(34): fatal error: Internal error: get_rule(). *** Error code: 1 *** Done.
From the code that you pasted, I'm not able to figure out what the problem is. The
if
condition looks perfect. Is that on line 34 of main.c?«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
From the code that you pasted, I'm not able to figure out what the problem is. The
if
condition looks perfect. Is that on line 34 of main.c?«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Yes. Its line # 34 in main.c When I remove
if
statement and just setlStructSize
to one of the values, the code compiles perfectly.It seems that there is nothing unusual. Give it a try by changing the name of the function "win98". It might confuse the compiler? :)
-
GetOpenFileName() is Win32 API function which accepts a pointer to a OPENFILENAME structure. In this structure, you have to set up a member lStructSize to sizeof(OPENFILENAME) for Windows XP and above. But for Windows98 it must be OPENFILENAME_SIZE_VERSION_400. When I use an if statement to do it, compiler gives fatal error and stops :
OPENFILENAME ofn;
if(win98()==FALSE)
ofn.lStructSize = sizeof(OPENFILENAME); //for Windows XP
else
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; //for Windows 98/MEOfcourse I can make seperate functions for opening files in win98 etc. But what is a better way to do this. Thank you