|
Dir all.
How i can know my progarme run form exe file or release mode of VS.
Example :
...
// run by F5 in VS
#if ! define (ABC) // i try _DEBUG and NDEBUG but it ca not check
messagebox("run by VS");
// run by double click in exe file
#else
messagebox("run by it selft");
#endif
...
|
|
|
|
|
First of all, macros are evaluated during compile time, not runtime, your #if !defined... thing will be "built into your exe" when you build your program, and then no matter where you run your program from this won't change your already built exe.
A way you could do this is by giving a command line parameter to your program in visual studio and then checking the existence of this parameter in your exe, if it is there, you runned your program from VS, if it is not there, you runned it by doubleclicking it in an explorer window for example.
Does this help?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi,
Is it possible to find out file location using C language in Windows programming?Is there any function in C language which can display the file location?
|
|
|
|
|
Could you please elaborate?
For instance what would be the input of such function?
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]
|
|
|
|
|
hi,
i think that if i can found the location of the file so i can give that location of the file to my c program which would act as input.doing this that c program can read or whatever i want.
|
|
|
|
|
From your previous post, I may guess you need the file location, given mouse pointer position as input. If you need this the you've to write a shell extension, hence the link I provided.
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]
|
|
|
|
|
hi.
firstly i want to say very very thank you. actually i want to do all the work in C .can it is be possible that without writting shell extension which you have provide me i can do all that job?
|
|
|
|
|
AFAIK writing the shell extension is by far the simplest way to do it. Michael's articles are really good stuff, have a look at them.
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]
|
|
|
|
|
hi,
i understand what you want to say. but my problem is that i want an exe file that can do all those job.
|
|
|
|
|
ravi 12 wrote: Is it possible to find out file location using C language...
What file?
"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
|
|
|
|
|
hi DavidCrow,
actually there is a order.docx file in my PC.I have placed it in D:\important\order.docx location. I want to know that can i find out it location using C Language?
|
|
|
|
|
ravi 12 wrote: I have placed it in D:\important\order.docx location. I want to know that can i find out it location using C Language?
This makes absolutely no sense. If you already know the location of the file, what's the problem?
If the file's path & name are being passed to your program (via a command-line argument), you have access to that using __argv . With that, you can then use _splitpath() to extract the various pieces. Also have a look at PathRemoveFileSpec() .
"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
|
|
|
|
|
hi DavidCrow,
actually this programming is a part of my project.so don't be confuse.I am now telling you about my project.Actually i have a C program which can read/write a file of extension .docx.means that c program can read/write the *.docx.so first i have to give input to that program .i mean that i have to give name and location of the *.docx file.So for its input i want that when i simply one click on any *.docx file it would be input for that program.Its my project.now i am thinking that when i simply one click on any *.docx file i would be able to know its location by C programming. I think that it should be now clear to you that what i want to ask you...
|
|
|
|
|
ravi 12 wrote: so first i have to give input to that program .i mean that i have to give name and location of the *.docx file.
Where? How?
ravi 12 wrote: ...when i simply one click on any *.docx file...
From where? Windows Explorer?
ravi 12 wrote: ...i would be able to know its location by C programming.
Do you have a WinMain() function?
"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
|
|
|
|
|
Hi DavidCrow,
That *.docx file can be anywhere in my computer.So i want when i would be that location and if i simply one click by mouse, the C program which i mention early starts read it contain.Don't be confuse.
Suppose that file is in D:\files\my.docx location I want to do is that when i click on my.docx file that C program starts reading its contain.If it is in another location the same case would be happaned there.
Ya i have winmain() function and i also include windows.h #include<windows.h>.but further programming related to mouse , i don't know .So please tell me that part of program in detail.please
|
|
|
|
|
I told you before: create a file association in explorer. Name your program as the handler for .docx files. Then double clicking will load your program with the filename as an argument, just like clicking a Word-document start Word with the document opened
Rozis
|
|
|
|
|
Hi Rozis,
Thanks for your suggestion...
|
|
|
|
|
Alright, you asked for it!!!
You ave to traverse the file system, looking for the file you're after. (Recursion is the most oft used approach)
You'll need the functions FindFirstFile and FindNextFile.
'All' you have to do is start out in the root directory of any drive and do a FindFirstFile Followed by a FindNextFile (looking for *.*)
until you have retrieved all of the filenames in the current directory, or found your target.
Then, you have to check the file attributes to determine which files are plain files and which files are actually directories.
You must then remember a list of those directories, and one by one scan the contents of each of them.
Simply repeat these steps for all files on a drive, or until the file is found.
Here. This'll list the contents of D:\ (without traversing any directories)
#define UNICODE 1
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
WIN32_FIND_DATA foundFile;
HANDLE firstFile;
WCHAR* searchString = L"D:\*.*";
firstFile = FindFirstFile(searchString, &foundFile);
do {
printf("%S\n", foundFile.cFileName);
} while (FindNextFile(firstFile, &foundFile));
return 0;
}
|
|
|
|
|
Hi,
I want to know about mouse programming.Actually i want to do is that there is a *.docx file in my computer(windows-XP)and i have a c program which can read the content of *.docx file.so first i have to give input(the location of the *.docx file) to that C program then it can read the content of that *.docx file.I want that when i click on *.docx file then it will be input for that C program.I want to ask you also that can i find file location by using mouse programming?So how can i do this???
|
|
|
|
|
May I ask you politely to avoid shouting?
ravi 12 wrote: Hi,
I want to know about mouse programming.Actually i want to do is that there is a *.docx file in my computer(windows-XP)and i have a c program which can read the content of *.docx file.so first i have to give input(the location of the *.docx file) to that C program then it can read the content of that *.docx file.I want that when i click on *.docx file then it will be input for that C program.
I strongly suggest you to read articles in this series [^].
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]
|
|
|
|
|
Why do you write in BOLD and what is "mouse programming"?
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Please don't keep repeating your question, i think you are posting it at least the third time. You already got an answer from 3 different people (file assiciations), if this does not give you the solution you are looking for you should try asking differently, preferably giving more detail about what exactly you wish to do. Also mentioning that file associations is not what you want could help avoid getting this same answer over and over again. Good luck...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
thanks for your reply. i cannot continue with my code for the reason that i dont have enough knowledge on it. My code is successful if i will not use radio button in getting the reasult but when i used a radion button to connect to the command button i cannot successfully link to it coz i dont know the code on how to do it. I just need a sample code for my reference...can u send sample code to connect the radio button to a command button please...?
Neil
|
|
|
|
|
I believe we had given a solution for this.
do you want to pass the value that is assigned to the radio button to the command button?
if that is the case create an event for the radio button and inside the function assign a value(say .10 which is 10%) to a global variable. Then use this global variable in command button.
Hope this helps you.
|
|
|
|
|
i will try sir but if still i cannot please dont stop helping me...
thanks a lot.
neil
|
|
|
|