Reference $(SolutionDir) in resource file VC++ - c++

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"

Related

How can I import COM .tlb file into C++ file with relative path?

I have a COM .tlb file and I want to import into my c++ project without using the absolute path of the tlb file. How can I do this?
I'm using Visual Studio and there are some C# and C++ projects. One of my C# project register COM object and generates .tlb file. After that I want to use this file with another C++ project. So I tried to import it. With absolute path (.tlb file location is my solution output directory) works properly (1) and I can also use relative path (2), but what I want to use for import is (3). The main reason for this is very simple I want to avoid to use Debug or Release path in my code. I found a solution for this (4), but when I try to build my solution (e.g in Release mode) then it also wants to read the Debug file and I think this is not the best solution (First of all I have to build my COM C# project in Debug and Release and after that I will be able to build my entire solution). So my question is that, Which C++ project option has effect to the #import? I tried to set VC++ Directories -> Library Directories to $(SolutionDir)$(Platform)\$(Configuration)\ but it didn't work. Thank you for your help in advance!
(1)
#import "C:\MyProjects\Project\x64\Release\myfile.tlb
or
#import "C:\MyProjects\Project\x64\Debug\myfile.tlb
(2)
#import "..\x64\Release\myfile.tlb"
or
#import "..\x64\Debug\myfile.tlb"
(3)
#import "myfile.tlb"
(4)
#ifdef RELEASE
#import "..\x64\Release\myfile.tlb"
#else
#import "..\x64\Debug\myfile.tlb"
#endif
When I try to use #import "myfile.tlb" with the following option:
VC++ Directories -> Library Directories to $(SolutionDir)$(Platform)\$(Configuration)\
Maybe the path of this .tlb file ("C:\MyProjects\Project\x64\Release\myfile.tlb")
is NOT added to '$(SolutionDir)$(Platform)\$(Configuration)\' .
Please, check that the value of '$(SolutionDir)$(Platform)\$(Configuration)\' and add the path of your .tlb file to it hence helping Visual Studio to find the .tlb file.
OR maybe copy the .tlb file to one of the directories which is already in '$(SolutionDir)$(Platform)\$(Configuration)\'
Another suggestion : Also check if the .tlb is correctly registered.
hope this helps !!

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.

Using the MFC dialog editor to add event handlers with a resource-only DLL

Originally my MFC program had one .rc file that includes resources for two languages. But, now I have two .rc files in two separate resource-only dll projects(in the same solution), and use LoadLibrary() and AfxSetResourceHandle() to select language dynamically(I referenced this article).
It seems working well, but one problem is that I cannot use dialog editor properly for dialogs in resource-only dll projects. It shows dialogs normally but I cannot add event handler by double-clicking a control or by using property menu. Is there any way to connect code and resource files which are in separate projects in the same solution?
EDIT:
I changed the approach slightly. Instead of creating new RC files in separate resource projects, I created them in the main project and excluded them from the build. And I made them to be referenced by separate resource projects.
One important point was that I added #include "resource.h" into Read-only symbol directives of each RC file(You can do this by right-clicking the RC file in Resource View and choosing Resource Includes item). "resource.h" here is the one that is related to the main project's original RC file which has resources for multiple languages. I don't know why I should add it, but it seems necessary for satellite dll to be working well.
One problem remaining is how to maintain that multiple RC files. For adding resources, if I should maintain original RC file and its resource.h file, I might have to add resources first into the original RC file and then copy them into every language specific RC file. Is this right method, or can I go on without the original RC file?
Include the RC file for this resource only DLL into the project too. But exclude it from the build.
If you have two resource files. Use resource file in a different way:
Create a stand alone program with a normal MFC resource file...
Use language tags for all dialog resources internally
Than use this resource in a second project to build the satellite DLL
Set the resource compiler defines so that the resources tagged with the specfic language are not included.

Asking admin rights c++ windows

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.