|
HI all
I have a piece of code in C which fails . This function tries to open a .wav file ..
The function is
int audio_file =open(filename,flag,AUDIO_PERMISSION);
if(audio_file<0)
{
\\ ...failure to open file so restart the CPU
}
The return value as defined in errno.h is EMFILE=24 => "Too many files opened"
What could be the reason for this failure and how to prevent it ? This problem has not been reproduced by me but only at a customer's site .
Can anyone please help me ?
redindian
|
|
|
|
|
dharani wrote: The return value as defined in errno.h is EMFILE=24 => "Too many files opened"
What could be the reason for this failure...
Too many open files.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
dharani wrote: What could be the reason for this failure and how to prevent it ?
Are you sure you close the file in all code paths after you are done with it?
|
|
|
|
|
You could possibly prevent it by using CreateFile and tracking window handles instead of using open, which has a smaller number of open files constraint on it.
Also, does the customer have any kind of quotas in force? Perhaps 'too many open files' is in response to some other error the process encountered while trying to open the file?
|
|
|
|
|
Hi Blake
I can not use CreateFile as the code is done in a linux environment - we use GCC.
What do you mean by 'open file constraint' ? Can you please eloborate it ?
Blake Miller wrote: Also, does the customer have any kind of quotas in force?
What do you mean by 'quotas' - this is the first time I hear this , please tell me more
redindian
|
|
|
|
|
This is the Visual C++ / MFC discussion board, which implies a Windows environment!
Why didn't you tell us you are working i Linux? Here, people has been trying to figure out a reason why this happens in a Windows machine!
A guick google search[^]gave me 84000+ responses.
Try it.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
I had assumed Windows operating system. An administrator can enforce quotas on user accounts - how much disk space used, how much memory allowed for process, etc. Any one of these could have caused your files to fail to open.
Typically, there is an interna table int he C runtie libraries that has a limited number of entries for mapping 'c' file handles to the OS internal data. Once you use up all these entrries - no more open files!
|
|
|
|
|
Have you tried scaling this down to a more manageable problem? Something like:
char szFile[256];
for (int x = 0; x < 100; x++)
{
sprintf(szFile, "Test%03d", x);
if (open(szFile, ...) == -1)
{
printf("Failed after opening %d files\n", x);
break;
}
} Now when open() fails, note the value of x .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
How will i disable CD drive. some code would be helpful.
with regards
RYK
|
|
|
|
|
You can disable/enable CD drive by editing registry.
In order to disable CD drive:
RootKey=HKEY_LOCAL_MACHINE
Key to open: "SYSTEM\\CurrentControlSet\\Services\\cdrom"
WriteInteger("Start",4)
Start is the name of REG_DWORD value, and 4 is the proper data for that value
In order to enable CD drive:
RootKey=HKEY_LOCAL_MACHINE
Key to open: "SYSTEM\\CurrentControlSet\\Services\\cdrom"
WriteInteger("Start",1)
Start is the name of REG_DWORD value, and 1 is the proper data for that value
Your application has to have administrator privileges
I've tried it with Windows 2000 and it worked
|
|
|
|
|
Through code you can do this way,
HANDLE hfile;
PREVENT_MEDIA_REMOVAL pm;
DWORD inBytes=sizeof(pm),retBytes=0;
hfile=CreateFile("\\\\.\\E:",GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); //assuming E: is CD Drive
if(hfile!=INVALID_HANDLE_VALUE)
{
pm.PreventMediaRemoval=TRUE; //set it to FALSE when u want to enable ejection
if(DeviceIoControl(hfile,IOCTL_STORAGE_MEDIA_REMOVAL,&pm,inBytes,NULL,0,&retBytes,NULL))
printf("CD Locked");
else
printf("Failed to lock\n");
CloseHandle(hfile);
}
else
printf("Failed to open handle,Errorcode=%d\n",GetLastError());
|
|
|
|
|
By this way we can lock the CD-Rom(ejection dont work)but i want, ejection work as it is and when i put CD then CD contains should not be read.
some source code would be appreciable
Thanks in advance
RYK
|
|
|
|
|
i need to display ipaddress gateway dns and subnetmask details in a dialog. is there any program to display this.
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
deeps_cute wrote: is there any program to display this
Yes, you can get to it from the Network control panel applet (ncpa.cpl on XP) and Start->Settings->Network Connections on XP.
Are you trying to ask about the APIs to use to get the values so you can show them in your own application in its own dialog?
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
yes i have to use the APIs to get the values and then displaying in corresponding edit box in dialog
-- modified at 8:14 Tuesday 6th March, 2007
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
There are several ways to obtain this information. See here for one such way.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
deeps_cute wrote: is there any program to display this.
Yes, use ipconfig.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i used the link you send but i cant get the DNS server. how to get this. i cant use ipconfig
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
deeps_cute wrote: ...i cant get the DNS server. how to get this.
Do you know its name or IP address?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i can get the dns server address from dos mode using "netsh interface ip show config". but the thing is i have to get all these using APIs. i downloaded a projetc viewadapter. here it displays only ipadderss, subnetmask and gateway. i need dns. is there any funcion to get this?
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
deeps_cute wrote: i need dns. is there any funcion to get this?
It's likely coming from:
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{your_interface_here}\DhcpNameServer.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
I have a big problem about creating a Simple Tab View Control in a MFC CDialog Dialog window. I must not create additional child dialogs to use in Tab Control because the Tab View must be kind of dynamic. Because of window resizing and manual control drags. Please tell me with code and or tutorial, how to create a MFC CDialog compatible Tabbed View control which doesn't uses any child dialog templates which we need to create in resource file. I am using Visual Studio .NET 2003.
Respectively,
Tushar
Tushar Arora
|
|
|
|
|
Hi,
If I understands correct what you are seeking is a way to create
a Tab whitout a dialog.
You can just put a tab control in your View class and than create that
control with its Create method.
Just check the MSDN for the tab control (CTab). They have really good explanations.
If you still having trobules tell me and I will try to find a program that will help you.
Sincerely yours
Y.R.
|
|
|
|
|
Hello,
You have advised me to look for "CTab" in MSDN but I haven't found any "CTab" class niether in Visual Studio nor in MSDN. I am using Visual Studio .NET 2003, and MSDN June 2005. I still need a code to create a Tabbed Control which doesn't need any Child Dialog templates to put in. Please help me.
tushar
Tushar Arora
|
|
|
|
|
I guess you are using MFC....
Where I have written CTab I should have written CTab... (I didnt checked the full name).
Anyway after a little check in the msdn site I found this page
http://msdn2.microsoft.com/en-us/library/hfshke78(VS.80).aspx
It contains info about the CTabCtrl. Though the site is good I prefer the help in the program(VS) (just write CTabCtrl in the index).
If you still having troubles try to search for CTabCtrl in CodeProject they have a lot of usefull articles.
Hope I helped.
Sincerely yours
Y.R.
|
|
|
|