visual-c++

In place member initialization and aggregate initialization

和自甴很熟 提交于 2020-01-13 19:45:05
问题 I have this simple struct and a function taking it: struct S { int a; }; void foo(S){} foo({5}); This works fine. But if I change int a; to int a{0}; VisualStudio (2013 and 2015) complains: error C2664: 'void foo(S)': cannot convert argument 1 from 'initializer list' to 'S' I can't find corresponding rule for this in the documentation. But both gcc and clang accept this without problem. 回答1: struct S { int a; }; is an aggregate whereas struct S { int a {0}; // or int a = 0; }; is not an

Visual Studio 2010 and windows SDK 7.0a compilation error

别说谁变了你拦得住时间么 提交于 2020-01-13 18:20:11
问题 I am new to windows development world. I am having Visual Studio 2010 and windows SDK 7.0a installed on my machine. Any win32 application (even the skeleton generated using the wizard) is giving me this compilation error repeated hundreds of times: 2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdio.h 2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\crtdefs.h 2> Note: including file: C:\Program Files\Microsoft Visual Studio

Windows Credential Provider, Filter, and Unlock Workstation Scenario

被刻印的时光 ゝ 提交于 2020-01-13 14:57:14
问题 I'm developing a credential provider and filter. I have some problems with lock scenario. First, I have tried the SampleAllControlCredentialProvider from here. And it works. Even when I logon and lock it afterward, it shows my credential. Second, I tried making my own credential provider filter by adding some lines of codes. The filter is filtering out the windows' credential, only my credentials are allowed to appear. These are my addition of codes: In CSampleProvider.h, I make the class to

Atomic operation on queue<T>?

柔情痞子 提交于 2020-01-13 14:53:35
问题 I should implement a class in Visual C++ with a queue; in this queue I've to do atomic operation. Searching on the web, I found the class std::atomic , but I keep some questions. The first is: what's the difference among: A) atomic <queue <T>> fifo; B) queue <atomic <T>> fifo; ? The second question is: how can I make atomic operation like push? push (T.load) is the right solution? The last question is: if I protect some operation on a queue with a mutex, still I have the need to do atomic

manual object constructor call

亡梦爱人 提交于 2020-01-13 11:29:48
问题 Can you please tell me if it is possible to call object constructor manually ? I know it's wrong and I would never do something like that in my own code and I know I can fix this problem by creating and calling initialization function, however the problem is that I stumbled at a case where there are thousands of lines of code in object's and its parents' constructors... class MyClass() { MyClass() { } virtual ~MyClass(); void reset() { this->~MyClass(); this->MyClass::MyClass(); //error:

how to get USB hardware id using device id?

谁说胖子不能爱 提交于 2020-01-13 11:24:15
问题 How to get hardware id of the usb device using device id...i am using vc++6.0 and OS is xp. is it possible by using wmi. 回答1: Finally i solved my problem...thanks for your replies... I am posting the code here, it may be useful for someone... by this code we can get all hardwareids of the devices which are connceted to our system.. HDEVINFO hDevInfo; SP_DEVINFO_DATA DeviceInfoData; DWORD i; // Create a HDEVINFO with all present devices. hDevInfo = SetupDiGetClassDevs(NULL, 0, // Enumerator 0,

how to get USB hardware id using device id?

别说谁变了你拦得住时间么 提交于 2020-01-13 11:24:07
问题 How to get hardware id of the usb device using device id...i am using vc++6.0 and OS is xp. is it possible by using wmi. 回答1: Finally i solved my problem...thanks for your replies... I am posting the code here, it may be useful for someone... by this code we can get all hardwareids of the devices which are connceted to our system.. HDEVINFO hDevInfo; SP_DEVINFO_DATA DeviceInfoData; DWORD i; // Create a HDEVINFO with all present devices. hDevInfo = SetupDiGetClassDevs(NULL, 0, // Enumerator 0,

How to add MFC support to existing Win32 C++ Project?

不羁岁月 提交于 2020-01-13 10:53:13
问题 I am creating a C++ application which uses Qt to create the GUI. However, I need to use a third party library which relies on MFC (for CString's, etc). Is there anyway to add MFC to my application to allow me to use this library or do I need to rewrite it myself? I saw this question, but it doesn't tell me how to add MFC manually to the project. 回答1: If the library app takes/returns/uses CStrings it will need linking with the MFC libs, or will have the MFC libs already statically linked. If

4d mapping in C++?

拟墨画扇 提交于 2020-01-13 10:43:08
问题 Can you please tell me how I can write multidimensional map. For two dimensional map, I did the following: map<string, int> Employees Employees[“person1”] = 200; I was trying to use something similar to following for 4d mapping. map<string, string, string, int> Employees; Employees[“person1”]["gender"][“age”] = 200; Can you please tell me the correct way to do this? 回答1: map<string, map<string, map<string, int> > > employees; employees["person1"]["gender"]["age"] = 200; 回答2: You normally want

Is it possible to attach a non-console Win32 application to the invoking cmd shell?

浪子不回头ぞ 提交于 2020-01-13 09:36:15
问题 When I have a Win32 non-console application (AFAIK, the console-ness of a Win32 app is linked into the exe), starting it from the console cmd.exe will return to the command prompt immediately, running the application "in the background" (o.c. it can have a GUI of sorts, or even open its own console window) Is it possible in the non-console executable to detect that it was launched from cmd.exe and "attach" it to the launching cmd.exe? And note that there are various questions/answers related