|
In Vista, all programs run with low privileges by default even if the user has admin privileges. You have to elevate it to run with admin privilege by right clicking on the EXE and selecting "Run as Administrator".
«_Superman_»
|
|
|
|
|
Thats looks fine.
But how can I do that programtically coz when I deliver my product to the customer it has to be done implicitly, we can ask the user/customer to run in using the context menu(using right click)...
Do we have any other approach of doing this programatically?
|
|
|
|
|
You can specify the required privilege in the application manifest file which is an xml file.
Please check some documentation on how it is done.
«_Superman_»
|
|
|
|
|
|
Hi everyone,
Iam tryingto create a new dll in win32.
I am very new to vc++ environment. Please help me to test the application. I want both th dll and a test application in the same workspace so that I dont have to copy past the output dll everytime I update the dll project.
I have created a win32 dll. And I have added a new mfc(exe) project to the workspace to test my dll. I have given the output filename path of the dll to the mfc project.
is all my setting correct?
Can I write a small printf statement in the dllmain function to test my dll by running it (running the dll project?).
Thanks in advance
I am a learner Always
|
|
|
|
|
himangshuS wrote: I have given the output filename path of the dll to the mfc project.
Or you can set the working folder of exe project as the dll folder, to avoid dll copy.
himangshuS wrote: Can I write a small printf statement
printf is a console function. So AFAIK, you need the exe as a console app. If it is window/dialog app, then you can use
::MessageBox( 0, "My message", "From my dll", MB_SYSTEMMODAL );
himangshuS wrote: test my dll by running it (running the dll project?).
Yes, you can set the active project as dll and set the "executable for debug" as the exe. Also you can set the project dependency so that building of projects will be easier.
- ns ami -
|
|
|
|
|
Thanks for your reply,
But, am still not able to test it. Could you please give me the clear steps necessary for the same? I have classes in my dll file. Do I have to copy them to my testing application folder?
I am a learner Always
|
|
|
|
|
himangshuS wrote: Do I have to copy them to my testing application folder?
No...
I assume that you have two projects (and you are using VC6 for instance).
Let me say, "dll.dsp" and "exe.dsp". And you have one workspace, say, "all.dsw".
You should insert (using Project menu) dll.dsp and exe.dsp to the all.dsw.
Set the active project as dll project. You will get these from Porject menu.
Set the "executable for debug" for dll project as the exe (output of exe project) in Project > Settings... > Debug(Tab) > "Executable for debug session"
Also set the working folder as the dll's folder (dll\debug or dll\release)
Now you can run the project. It will automatically execute the exe in order to run the dll.
Hope these are clear to you...
If you are making the exe project as active project, set the dependency for exe project as dll project. So that you dont need to build the dll each time you change its code.
- ns ami -
|
|
|
|
|
Thanks,
I got all the settings. Nut Now when I try to create a object of a class(of dll) in my testing application(exe), it says.. undeclared identifier...Why is this?
Thanks in advance
I am a learner Always
|
|
|
|
|
You have a exported class, right?
Are you sure you included the header of that class in the test app?
- ns ami -
|
|
|
|
|
I am really sorry for the basics. Could you please tell me how to export and necessary include statements...also if any other settings has to be changed for dll file
Thanks
I am a learner Always
|
|
|
|
|
himangshuS wrote: I am really sorry for the basics
You should study some basics for dll class exporting.
#ifdef DLL_EXPORT
#define DLL_IMPORTEXPORT __declspec(dllexport)
#else
#define DLL_IMPORTEXPORT __declspec(dllimport)
#endif
class DLL_IMPORTEXPORT CMyClass
{
};
And you have to specify the "DLL_EXPORT" in Project > Settings > "Preprocessor definitions"
And in the test app you can just include the header and use. Also you need to specify the lib file of dll. It is available in the Link(tab), Input(catagory) of the project settings. Give the path to the lib in the "Additional library path"
- ns ami -
|
|
|
|
|
When I try to compile the exe project it through an error
fatal error C1083: Cannot open include file:
When I specify the library file of the dll in the exe project, is it the same path as my ...dll_project/debug folder?
Thanks
I am a learner Always
|
|
|
|
|
himangshuS wrote: fatal error C1083: Cannot open include file:
Check yourself the file path and existance of the file.
himangshuS wrote: When I specify the library file of the dll in the exe project, is it the same path as my ...dll_project/debug folder?
Yes, path where your dll's .lib file exists.
- ns ami -
|
|
|
|
|
still the same error...i checked the file existence...it exist in the dll project folder...not in debug,(but dll' main_application folder)....Do i need to copy paste the header files into the application project workspace..I hope not..
I am using vc++ 6 version.
my trest appplication is mfc, and dll is win32 dll
Regards,
Himangshu
modified on Monday, February 2, 2009 5:24 AM
|
|
|
|
|
You have to set the include path in Test App's Project settings > Preprocessor(catagory) > "Additional include directories"
Eg: "../DllProjectFolder/" or "D:/DllProjectFolder/"
And in the source, you can include the header like
#include <dllmyclas.h>
- ns ami -
|
|
|
|
|
Thanks a lot ns ami
It worked,...But, here is another problem exist..
I had to make my class methods as public.(it was giving the error)..And I made it also...Now when I compiled my dll and then compiled the test application its giving error...
error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall <<b>class_name>::<<b>method_name>(void)" (__imp_?method_name@class_name@@QAEHXZ)
Debug/testing.exe : fatal error LNK1120: 1 unresolved externals
I am a learner Always
|
|
|
|
|
I think, the lib is not properly included to the test app project.
- ns ami -
|
|
|
|
|
I have included the path ".....dllproject/Debug"
in the additional library path...
Is there anything else I need to do?
Regards,
Himangshu
I am a learner Always
|
|
|
|
|
i got it right....
I gave/specified the library/module name also...
Thanks a lot anyway...
But here is another problem....My dll uses an another dll...when i run my test application it says" the application failed to initialize properly...." is it the problem of my 3rd party dll?...or what it could be...
Thanks a lot ns ami
I am a learner Always
|
|
|
|
|
Doesn't the message say the module that is missed?
Check the dependencies using "C:\Program Files\Microsoft Visual Studio\COMMON\Tools\DEPENDS.EXE"
If anything is missing then you can identify that.
- ns ami -
|
|
|
|
|
sorry ns ami,
As I said am a beginner. I did not understand dependencies.
What I found out is that it allows me to create a object of a class of dll, but it rises that error when i try to call a method using the object
thanks
I am a learner Always
|
|
|
|
|
You have to check what is done in that function first, before I can help you. Try to debug the code also.
- ns ami -
|
|
|
|
|
Hi again,
If I try to create an object of a class fo dll in my application , no probs. But if I call a member function it shows...
"application failed to initialize properly.click ok to terminate the application"
please help me
Thanks
I am a learner Always
|
|
|
|
|
himangshuS wrote: But if I call a member function it shows
Please read my previous post.
- ns ami -
|
|
|
|