Asking admin rights c++ windows - c++

Im very new in C++
I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to ask admin right to windows.
I have created .manifest file added this
#define MANIFEST_RESOURCE_ID 1
MANIFEST_RESOURCE_ID RT_MANIFEST "MyAPP.exe.manifest"
To my main.cpp under #includes
visual studio says: expected a declaration.
What i am doing wrong?
Thanks

As it states in the link you provided:
The following lines in the .rc file would embed the manifest above if
it were saved as Ad­min­App.exe.man­ifest:
#define MANIFEST_RESOURCE_ID 1
MANIFEST_RESOURCE_ID RT_MANIFEST "AdminApp.exe.manifest"
Your C++ project needs a resource file, and these lines belong in the .rc file, not your main.cpp
Don't forget to create your manifest file too.

Related

Reference $(SolutionDir) in resource file VC++

I'm trying to build a solution which contains two projects:
COM Dll
Application using this DLL
In the COM dll, I'm trying to embed the tlb generated from the idl in the project. I have usual configuration Debug-Release and Win32-x64 pair. Now, depending on this, the tlb file is created in different path which can be referenced via $(SolutionDir)Project1\$(IntDir). How do I make my resource file reference this file each time I build with different configuration pair? Here's part of my .rc file:
#include <windows.h>
1 TEXTINCLUDE DISCARDABLE
BEGIN
"1 TYPELIB ""CalcCOMObject.tlb""\r\n\0"
END
// More info block code...
#ifndef APSTUDIO_INVOKED
// Please suggest in the line below:
1 TYPELIB "x64\\Debug\\CalcCOMObject.tlb"
#endif
I'd prefer if the resource file would still be editable in the resource editor. I'm using VS2015 to build my project. Thanks!
You pass /I $(SolutionDir)Project1\$(IntDir) to RC.EXE; in Visual Studio properties this can be found under "Resources>Additional Include Directories"

how to include rcdata in a exe file included in a .rc2 file,which is included in a dll file

I am creating a project in vs2017, i have created a "windows desktop wizard-windows Applicatio(.exe) project" and i have included "windows desktop wizard- dynamic link library(.dll) project.
I have included all the resource file in the dll file.i have to include localized language string of the application.i have .rc2 file available which has different strings defined in a specific language.I have 40 .rc2 files each containing RCDATA(cum string) in different languages and i am trying to load those RCDATA from my exe project.
i got the handle of the dll,but when i am using the following code i am getting NULL.
hHRSRC = FindResourceEx( hInst, RT_RCDATA, MAKEINTRESOURCE(ID), langid);
where hInst= handle of dll;
Id= id of the RCDATA defined in .rc2 file
PS. when i am including all the .rc2 files in my exe project,it is working properly.
getlasterror() giving the error no. 1814. so i guess RCDATA is not defined to exe project,how can i define it and is there any specific way to add .rc2 file in the dll project which enables the project to read it!?

need help to create first c++ console applciation

i'm a c# developer, have no experience on c++. I'm trying to create a c++ console application from this code:
http://www.oblita.com/interception.html
i downloaded the sources and registerd with install-interception.exe
in visual studio 2015 i created a new console application and added interception.h under Header Files.
in ConsoleApplication1.cpp added this code:
#include "stdafx.h"
#include <iostream>
#include <interception.h>
#include "utils.h"
using namespace std;
int main()
{
return 0;
}
when building i get this error:
Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'interception.h': No such file or directory ConsoleApplication1 d:\documenti\visual studio 2015\projects\c++\consoleapplication1\consoleapplication1\consoleapplication1.cpp 6
To paraphrase #Biffen:
Adding a header file to a project and telling the compiler where to look for header files are two different things.
MSDN describes how to do tell the compiler to look for the header file:
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Click the C/C++ folder.
Click the General property page.
Modify the Additional Include Directories property.

Trying to build existing project, lots of "Cannot open include file: 'StdAfx.h': No such file or directory"

I've been handed the source code for a very large c++ project and asked to make a small change to support some new hardware. I'm not very familiar with c++, as I mostly use C# these days.
When I built the project I'm getting 20+
Error 2 error C1083: Cannot open include file: 'StdAfx.h': No such file or directory D:.. thefile.cpp
From my understanding the "StdAfx.h" is to do with precompiled headers, and is automatically generated?
I followed the answer on this question:
1 Ensure you have the file "stdafx.h" in your project. If you don't
(e.g. you removed it) just create a new temporary project and copy the
default one from there;
but in doing so noticed that the created stdafx.h file doesn't have the capitalisation of the referenced "StdAfx.h"
I managed to get rid of a single error by copying in the generated file from a new project and changing:
#include "StdAfx.h"
to:
#include "stdafx.h"
I can't help but think this project was using StdAfx.h (there are about 150 references to it) for a reason, and that I shouldn't be adding a bunch of stdafx.h and stdafx.cpp files scattered around the place.
Is there some way of referencing a global stdafx.h file that was being used that could be causing this error?
In Windows, file names are not case-sensitive.
You can't expect that someone else stdafx.h file will be useful in your project. You need to find the original one.
Typically, one project uses one header file for precompiled header, shared by every source file that includes it.

error C1083: Cannot open include file: 'stdafx.h': No such file or directory in VS 2005

I am new to visual studio.I have created a simple console application and then selected an empty project of c++.
I have pasted the code form
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html
it is giving the following error
error C1083: Cannot open include file: 'stdafx.h': No such file or directory.
Can any body help me how ti solve that issue.
Also i have pasted the code from
http://www.cprogramming.com/tutorial/opengl_windows_programming.html
and it gives me error in MessageBox function.
Fall in the pit of success by using an appropriate project template. Which is Win32 + Win32 Project, don't tick the "Empty project" option on the property page. You'll get pre-generated code for a Win32 application, take a look at it since you might want to keep parts of it. Or just delete it all past the #include for stdafx.h and replace it with the code you want to try. The stdafx.h file is already pre-cooked for you.
The second snippet probably fails to compile because the code sample is not using Unicode strings. Put an L in front of the string literal, like L"\tHello world".
"stdafx.h" is the default name for the precompiled header in Visual Studio.
If you are not using precompiled headers you can omit that include directive.
See this article on Wikipedia for an explanation of precompiled headers.