visual-c++

How to get token of logged-in user from within windows service with C++?

我是研究僧i 提交于 2021-02-20 03:55:30
问题 on windows vista & above, currently, I am enumerating all windows sessions, then once I find an active session, WTSQueryUserToken() is called which gives me the token of current user. This token is used to launch a process with his privileges / inside his desktop. Problem I am facing is that there is not reliable way to get the active session / interactive session. I have to wait (check its presence every few millsecs) until explorer.exe is spawned. I am not preferring notifications like

Why this Error: a value of type “const int*” cannot be assigned to an entity of type “int*”?

北战南征 提交于 2021-02-19 15:32:07
问题 This is my code: int i = 5; const int * cpi = &i; //pointer to const int * pi = cpi; //Error: a value of type "const int*" cannot be assigned to an entity of type "int*" 回答1: i is mutable, cause it is not a const type. You try to store a int address in a const int address via cpi . To solve it you have to actually hand over the values not the addresses. 来源: https://stackoverflow.com/questions/34542470/why-this-error-a-value-of-type-const-int-cannot-be-assigned-to-an-entity-of

Why this Error: a value of type “const int*” cannot be assigned to an entity of type “int*”?

邮差的信 提交于 2021-02-19 15:26:38
问题 This is my code: int i = 5; const int * cpi = &i; //pointer to const int * pi = cpi; //Error: a value of type "const int*" cannot be assigned to an entity of type "int*" 回答1: i is mutable, cause it is not a const type. You try to store a int address in a const int address via cpi . To solve it you have to actually hand over the values not the addresses. 来源: https://stackoverflow.com/questions/34542470/why-this-error-a-value-of-type-const-int-cannot-be-assigned-to-an-entity-of

Building System.Data.SQLite from Source, Builds with Target Framework 4.0

拈花ヽ惹草 提交于 2021-02-19 08:26:48
问题 I'm trying to build System.Data.SQLite in Visual Studio using the source code downloaded from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki I was able to build the solution, but when I tried to reference the System.Data.SQLite.dll from a project with TargetFramework=3.5, I received the following message: "System.Data.SQLite.dll or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project." I noticed that their managed

How to read a UTF-16 text file in C++17

不打扰是莪最后的温柔 提交于 2021-02-19 05:57:06
问题 I am very new to C++. I want to read a UTF-16 text file in C++17 in Visual Studio 2019. I have tried several methods in the internet (including StackOverflow) but none of them worked, and some of them didn't compile (I think they only support older compilers). I am trying to achieve this without using any 3rd party libraries. This reads a text file, but it has some weird characters and spaces between each letter. // open file for reading std::wifstream istrm(filename, std::ios::binary); if (

Adding references in Visual Studio project template?

爷,独闯天下 提交于 2021-02-19 05:55:07
问题 I'm creating a multi-project template for VS2015 where one of the created projects references the other. How do I add the reference using the template? If I add the reference using the VS GUI it will add the following to the .vcxproj file: <ItemGroup> <ProjectReference Include="path\xyz.vcxproj"> <Project>{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}</Project> </ProjectReference> And the GUID is a valid one, since VS knows the GUID of the referenced project. When I create the new projects from

What is __CxxFrameHandler4 and what does linker error “unresolved external symbol __CxxFrameHandler4” mean, exactly?

旧城冷巷雨未停 提交于 2021-02-19 04:24:05
问题 I'm using several libraries built through vcpkg (such as civet-web and prometheus-cpp), against my Visual C++ projects. When building x86 all is perfect, in x64 I get a bunch of linker errors: error LNK2001: unresolved external symbol __CxxFrameHandler4 Searching online all references to this symbol/error are about specific projects, I cannot find what __CxxFrameHandler4 is and what problem this error is highlighting. I don't know if it's a problem with the way vcpkg is building the library,

using strcpy_s for TCHAR pointer (Microsoft Specific)

坚强是说给别人听的谎言 提交于 2021-02-19 01:34:26
问题 I was wondering which is the correct way? _tcscpy(tchar_pointer, _tcslen(tchar_pointer), _T("Hello World")); or _tcscpy(tchar_pointer, _tcsclen(tchar_pointer), _T("Hello World")); or _tcscpy(tchar_pointer, ???, _T("Hello World")); 回答1: the tchar pointer are coming from external, and my side has no idea how large the buffer referred by the pointer is If this is so, then none of these do what you want. The way all the "safe" functions work is that you tell them how big the target buffer is. You

Visual Studio 2013 missing CLR Widows Form application template

帅比萌擦擦* 提交于 2021-02-18 17:46:25
问题 I was very surprise when I Tried to create Visual C++ Windows Form Application (CLR) in Visual Studio 2013 RC ultimate. I could not found any template for Windows form under CLR section. It was in Visual Studio 2010. I tried by using "CLR Empty Project" but by adding any windows form it got error. Error 1 error LNK1561: entry point must be defined Any solution for this? 回答1: This was a breaking change from VS2012. As it says on the above MSDN page, under Breaking Changes in Visual C++ :

Win API for changing input language programmatically

旧时模样 提交于 2021-02-18 11:31:20
问题 I want to change the input language in WinXP to Spanish, programmatically. Is there an API to support that? Thanks 回答1: LoadKeyboardLayout ActivateKeyboardLayout GetKeyboardLayout etc. 回答2: i managed to do it with keyboard events & shortcut assignment. go to "text services and input language" (that's how it's called windows 7 control panel) assign keys for the uni-directional language. e.g. "To English", and "To Hebrew". I've chosen Alt-Shift-7 and Alt-Shift-8, because they're rarely used