|
CFileStatus status;
if( CFile::GetStatus( OpenFile, status ) )
{
if(status.m_attribute==0x01)
AfxMessageBox(_T("readOnly"));
}
but the messagebox not displayed.or when i debug the code in place of status.m_attribute the '!' display.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
You have to put a mask on the attribute byte to check the read only bit:
if (status.m_attribute & 0x01)
|
|
|
|
|
"_$h@nky_" wrote: if(status.m_attribute==0x01)
It should read
if(status.m_attribute & 0x01)
m_attribute is a bit field which can contain more than one bit setting; check the documentation for the significance of the other bits.
|
|
|
|
|
Thanks
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I want to associate an extension to my MFC application - I know I can call RegisterShellFileType which will do some of that. My problem is that for a given extension, I do not want to start a new instance of my application... I'd like the current instance (ideally all instances but let's not get there right away) to be notified that they need to read the file.
If you're wondering why I want this : let me explain. I have this SDI application that creates documents (for lack of a better word). I want the users to be able to download some plugins (with the remarkable extension) from the wwww- and when they open the file from their browser, I want those plugins to be installed... I hope I am making sense!
Thanks in advance!
|
|
|
|
|
You would need to configure this into the browser so it recognises the file type and passes that file to the relevant application.
|
|
|
|
|
I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...
|
|
|
|
|
BadJerry wrote: I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...
Sorry, but your original question was not clear.
You mention associating a file type with your application, then talk about downloading files and sending them to your application. Could you clarify exactly how you expect this process to operate, including the interaction (or interdependency) between your application and the browser?
|
|
|
|
|
As I see it, you have two issues...
1/ You want a website, with files of some custome format (call it fwibble.badjerry). In the same way as a (eg) pdf, the browser will run an external application - badjerry.exe, or acrobatreader.exe.
2/ You only ever want one of these programs running, even if they click on multiple files.
I hope that's a reasonable summary.
1/ Is a non issue - use RegisterShellFileType as normal. Whether the file comes from a website, via a temp directory, or it comes from the users My Dcuments directory is irrelevant.
2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was:
Limiting an application to a single Instance - the MFC way[^].
I did find a bug with huge impact but a simple fix - look at my comment at the end of the article. Other than that, it was a joy to use. Just a daft error.
Enjoy,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
It's not exactly what I want : the badjerry.exe is not single instance - it can open many .pdf or .doc files but if it tries to open a .badjerry the exisiting instance should be used.
But you gave me an idea of how I could implement this - I could associate the .badjerry extension to another single instance program which will then relay the information to the other instances... or start one if there isn't... it's a bit long-winded but... hey...
Thanks for your help!
|
|
|
|
|
OK, I'm confused. Unless badjerry.exe is a browser in its own right, it as no business opening pdf files... (I assume it's not a pdf viewer).
And if it only handles .badjerry's, then the article I gave you a link to handles that - if a 2nd instance opens, it communicated with the first, to get the first one to open the desired file, then close the 2nd one.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Iain Clarke, Warrior Programmer wrote: 2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was:
Limiting an application to a single Instance - the MFC way[^].
The procedure from that article seems awfully complicated. I always use this code in InitInstance (if it's a MFC app, otherwise WinMain):
CreateMutex(NULL, TRUE, _T("Unique_String_Identifying_The_Application"));
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
return FALSE;
}
|
|
|
|
|
That's what I used to do to...
But that does nothing about running the previous (only) instance, let alone get the 1st instance to open any document that the 2nd instance had been... instantiated... to do.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
It was slightly off topic, I guess.
I'm still not quite sure what exactly the OP wants...
|
|
|
|
|
Hi All,
Is there an API in MFC to run internal test of a hard disk and know its status?
Regards
Abinash Mohanty
|
|
|
|
|
Seems very unlikely. The most likely way of being able to do that would be via an IOCTL[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Why would MFC care about something as low-level as that?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I think assembly is better than c++ for you.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I am in the process of re-writing an application. I cut and pasted the code to test if the OS and application are themed from the old version. Even though a manifest is in the resource file and the app clearly has themes enabled (all the controls are themed) the IsAppThemed function returns FALSE??? The code is:
bool WindowsTheme::CheckThemeActive()
{
PFNISAPPTHEMED pfnIsAppThemed = reinterpret_cast<PFNISAPPTHEMED>(GetProcAddress(themeDllHandle_, "IsAppThemed"));
PFNISTHEMEACTIVE pfnIsThemeActive = reinterpret_cast<PFNISTHEMEACTIVE>(GetProcAddress(themeDllHandle_, "IsThemeActive"));
if(pfnIsAppThemed && pfnIsThemeActive && pfnIsAppThemed() && pfnIsThemeActive())
return true;
return false;
}
IsThemeActive returns TRUE. The display settings under Properties for the .exe has visual styles enabled. I'm at a loss to explain what is happening so any help much appreciated.
|
|
|
|
|
Isn't it enough to check only IsAppThemed[^] for TRUE?
Also check in the drawing code weather OpenThemeData() is successful, when an application uses the old common controls (e.g. has no manifest or themes are globally disabled) calling this function will fail. Also see Using Visual Styles with Owner-Drawn Controls[^] (MSDN).
Hope this helps!
|
|
|
|
|
Well I found the answer to this, but am still at a bit of a loss to explain why. I went back to my original logic and commented things out until I reproduced the error. It turned out to be one line of code. If I commented out:
HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&m_dwCookie);
IsAppThemed returned FALSE. If I removed the comment, adding this line of code back in IsAppThemed returned TRUE.
|
|
|
|
|
Hi Andrew,
Interesting discovery. Are you able to reproduce this bug in a small VS2008 wizard-generated application?
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
I am trying to compile this program with Visual Studio C++ 2008 as the compiler in Windows.
It is the program:
#include <stdio.h>
int main()
{
FILE *fichero;
char letra;
fichero = fopen("origen.txt","r");
if (fichero==NULL)
{
printf( "No se puede abrir el fichero.\n" );
exit( 1 );
}
printf( "Contenido del fichero:\n" );
letra=getc(fichero);
while (feof(fichero)==0)
{
printf( "%c",letra );
letra=getc(fichero);
}
if (fclose(fichero)!=0)
printf( "Problemas al cerrar el fichero\n" );
}
It is the error message:
>1.......warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
>c:\archivos de programa\microsoft visual studio 9.0\vc\include\stdio.h(237) : vea la declaración de 'fopen'
>...error C3861: 'exit': no se encontró el identificador
--------
Could anyone help me?
|
|
|
|
|
Please next time before posting read the posting guidelines here[^] (and more specifically, the point 7).
For your question, did you include stdlib.h as stated in the documentation[^] for the exit function ?
|
|
|
|
|