|
override the definition of FOPEN_MAX in your code not in stdio.h
as
#deinfe FOPEN_MAX <n> //n is the value you need to set .
vineesh
|
|
|
|
|
Do you really think such a #define will be of any help?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The actual definition of FOPEN_MAX in stdio.h
is
#define FOPEN_MAX 20
you can extend it to some limit (around 500)
The below code works fine
#include <stdio.h>
#include <windows.h>
#define FOPEN_MAX 500
FILE *stream, *stream2;
int main( void )
{
int numclosed;
int fd =3;
while (fd <= FOPEN_MAX)
{
if( (stream = fopen( "E:\\new.txt", "r" )) == NULL )
{
printf( "The file was not opened\n [%d] ",GetLastError());
getchar();
}
else
{
fd = fileno(stream);
printf( "The file was opened and fd is [%d] \n " ,fd);
}
}
numclosed = _fcloseall( );
printf( "Number of files closed by _fcloseall: %u\n", numclosed );
return 0;
}
============
vineesh
|
|
|
|
|
I don't get the point of doing that. Please see here [^] (as Iain explained very well the real purpose of FOPEN_MAX ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes Iain was correct ...
The actual libary code restrict the number of file open to 510 (i dont know the exact value ..).But normally the system will not allow you to open more than 20 files from a process .This is because of the FOPEN_MAX set to 20 in the header stdio.h .
#define FOPEN_MAX 20
We can only change the value below 510 .
#define FOPEN_MAX 510 //upto this will work
that means
#define FOPEN_MAX 511 may not work as it trying to override the max limit in the actual libray code
We cannot open infinite number of files using fopen ,but still we can extend the limit set in the stdio.h file as above .
The usage of CreateFile is an absolute replacement for fopen if you need to open file more than 500 times from a single process.
vineesh
|
|
|
|
|
Why do you think you can set it?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The limit will be in the actual library code - the constant in the header is just to let you know about the limit.
You may be able to recompile your own version of the libraries with a higher max value, but there may be other factors causing the limitation.
Or you could use API functions like CreateFile instead. The limit for that is "May as well be infinite. If you need to know the actual limit, you're in bigger trouble than you think".
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
|
Hello Friends,
I am using Windows Vista and I am builing an c++ ATL DLL in Visual C++ 6.0, which is an addin DLL for Windows Mail. (Outlook Express)
When I run my Windows Mail, Vista's DEP (Data Execution Prevention) feature blocks it, and prompts that it blocked for security purpose as some other program tried to use windows mail data.
But I have to hook into Windows Mail as have to put an addin to customize its GUI.
I tried to turn DEP off for Windows Mail, but it didnt allow me (even in Full Admin Account).
Also I turned DEP off for my exe (which loads my addin DLL, which further hooks into Windows Mail), but despite that Windows Mail is blocked.
Also, when I build the project in Visual Studio 2005, it runs very well. (And I have not made any change in the project settings or code)
It seems, VC 6 uses older compilers and VS 2005 uses latest ones so are compatible with Vista!
But I have to use VC 6 only as it's my project's requirement!
Please Help!
Thanks a lot !!
dolly,
N,IN
|
|
|
|
|
Is it possible to use the ATL header files from 2005, but use the VC6 compiler?
Just a thought...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Iain Clarke wrote: Is it possible to use the ATL header files from 2005, but use the VC6 compiler?
Just a thought...
Iain.
As of now, no I am not able to do it.
dolly,
N,IN
|
|
|
|
|
Hi,
Can anybody help me in getting the VendorID and ProductID of a device separately. I need it for all classes of devices like Modems, Ports etc.
Thanks.
|
|
|
|
|
Does EnumDevices,EnumDisplayDevices... help
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
In my code i am using CreateProcessAsUser to create new process.The purpopse of the code to execute any of the process (console applicaions and window applicaions ) .The code is build as a service and after the CreateProcessAsUser ,the process id of the newly created process will be returned .The functionality works fine for window based applications (notepad ,regedit ..etc..) but when console applications such as cmd are passed to the CreateProcessAsUser ,the function returns process id ,but no such process informations are found in the task manager .. I think the newly created processes getting exitied as soon as they are spawned ..
Can any body help me in this ...
vineesh
|
|
|
|
|
can you show us the code?
|
|
|
|
|
I have a requirement in my app where I need to take some action at lets say - 24 hours after the app has opened.
Clear case of using timers, but timers take input in "milisecs", is it a nice idea to give timers with very high interval like 24 hours which will come out to be -
24 * 3600 * 100 milisecs.
Regards
Amit
|
|
|
|
|
When you start calculating 24 hours in milliseconds (86400000) then you do get big numbers.
And 2^32 can only hold 49.7 days, so I think your reluctance is very wise.
There are alternative ways though - have a look at SetWaitableTimer. You can also set it to call a function at a certain time / date, so it may be more useful to you.
Good luck,
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
well, actually your point is of great help to me. If it can store 49 days at max then I'll buy that as I only need it max for 24 hours which is considerably lesser.
Thanks a ton!
Cage
|
|
|
|
|
|
Iain Clarke wrote: And 2^32 can only hold 49.7 days
Actually is the half , see [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Still works for me hope it doesn't shrink
|
|
|
|
|
Well, my sums are accurate!
If you're going to cheat and read the docs and find that SetTimer can only do 2^31-1, then shame on you!
In my defense I was thinking of GetTickCount and wraparound. There are lots of ways of skinning his particular cat.
I certainly wouldn't do a 24hr SetTimer - what if people chage the clock? Twice a year that gets done for you, etc...
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Iain Clarke wrote: If you're going to cheat and read the docs and find that SetTimer can only do 2^31-1, then shame on you!
Shame on me!
Iain Clarke wrote: I certainly wouldn't do a 24hr SetTimer - what if people chage the clock? Twice a year that gets done for you, etc...
Do you think the timer would be affected (I really have no clue about but i suppose it shouldn't: it's a timer, not a clock!)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Do you think the timer would be affected
I also doubt the timer would be affected - but its usefulness would depend on what the OP is trying to do.
If it's "do something approximately a day later", then SetTimer would be fine, or checking GetTickCount on a more rapid timer.
If it's "do something at the same time tomorrow, and the user will look at their clock and be puzzled why they started the program at 1pm and it's midday now..." then you need to do it a different way.
It really depends on what (s)he's trying to do.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Well, timers and alarms are pretty different things, I suppose the OP knows about. But this is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|