visual-c++

Execution halts on “Microsoft Visual C++ Runtime Error”-popup

时光怂恿深爱的人放手 提交于 2020-01-24 11:27:45
问题 A project I am currently involved in uses JavaCv/OpenCv for face detection. Since the OpenCv occasionally throws an error, and the propagation of OpenCv/C++ errors to Java Exceptions isn't fully functional yet, this means the Java main-loop crashes with no way to recover. However, the code gives mostly accurate results, and since we're running it on a large database I baked a quick Batch-script around the execution to keep it going, and the Java code internally manages an id , to make sure it

Export function from a DLL - Use DEF file or dllexport?

白昼怎懂夜的黑 提交于 2020-01-24 11:08:28
问题 Module-definition (.def) files provide the linker with information about exports, attributes, and other information about the program to be linked. A .def file is most useful when building a DLL. Because there are linker options that can be used instead of module-definition statements, .def files are generally not necessary. You can also use __declspec(dllexport) as a way to specify exported functions. http://msdn.microsoft.com/en-us/library/28d6s79h%28VS.80%29.aspx I was wondering, should we

Getting a char* from a _variant_t in optimal time

旧巷老猫 提交于 2020-01-24 06:27:27
问题 Here's the code I want to speed up. It's getting a value from an ADO recordset and converting it to a char*. But this is slow. Can I skip the creation of the _bstr_t? _variant_t var = pRs->Fields->GetItem(i)->GetValue(); if (V_VT(&var) == VT_BSTR) { char* p = (const char*) (_bstr_t) var; 回答1: The first 4 bytes of the BSTR contain the length. You can loop through and get every other character if unicode or every character if multibyte. Some sort of memcpy or other method would work too. IIRC,

Getting a char* from a _variant_t in optimal time

a 夏天 提交于 2020-01-24 06:26:09
问题 Here's the code I want to speed up. It's getting a value from an ADO recordset and converting it to a char*. But this is slow. Can I skip the creation of the _bstr_t? _variant_t var = pRs->Fields->GetItem(i)->GetValue(); if (V_VT(&var) == VT_BSTR) { char* p = (const char*) (_bstr_t) var; 回答1: The first 4 bytes of the BSTR contain the length. You can loop through and get every other character if unicode or every character if multibyte. Some sort of memcpy or other method would work too. IIRC,

Windows theme affecting ListView header

江枫思渺然 提交于 2020-01-24 02:22:04
问题 I've created new Windows Forms Application (C#) with one simple form containing ListView. Then I have changed the View Property to Details and increased the size of the font used in this ListView and here's the result: This is how it looks on Windows XP with Windows Classic theme: and here's the result with Windows XP theme: I can prevent the appearance of my application to be affected by Visual Styles either by removing Application.EnableVisualStyles() call or by changing the Application

How to set C/C++ console text in bold and italic in Windows?

纵然是瞬间 提交于 2020-01-24 00:52:08
问题 I am developing an Visual C++ application in windows console mode, I want to set my console text in to Bold and Italic form. I changed console text color and background color using SetConsoleTextAttribute function and system("COLOR XX") functions. But there is no Win32 API function to changed text mode in to BOLD, Italic or Stroke. Please mention any function or mechanism to achieve it within C/C++ programming boundary in Windows environment? 回答1: This can't be done in Windows with the

C++ unit test testing, using template test class

夙愿已清 提交于 2020-01-23 06:22:26
问题 I’m doing some C++ test driven development. I have a set of classes the do the same thing e.g. same input gives same output (or should, that’s what I’m try to test). I’m using Visual Studio 2012’s CppUnitTestFramework. I wanted to create a templated test class, so I write the tests once, and can template in classes as needed however I cannot find a way to do this. My aim: /* two classes that do the same thing */ class Class1 { int method() { return 1; } }; class Class2 { int method() { return

Confused between logical coordinates and device coordinates in Windows API

感情迁移 提交于 2020-01-23 05:41:07
问题 I have been looking into a Visual Studio C++ Windows application project which used two functions SetWindowExt (...) and SetViewportExt (...) . I am confused about what these two functions do and why they are necessary. Searching about these functions, I came to the concept of logical coordinates and device coordinates. Can anyone please explain what is the importance of these two concepts? 回答1: Device coordinates are the simplest to understand. They are directly related to the device that

How to link a .lib in Visual Studio 2008 C++

北慕城南 提交于 2020-01-23 02:45:08
问题 I'm finding it really difficult to properly link a .lib file to my C++ Win32 Console Application. Here's my problem. Just as in this MSDN article, I have developed a MathFuncsLib.lib file. http://msdn.microsoft.com/en-us/library/ms235627%28v=vs.80%29.aspx Then, in the MyExecRefsLib Win32 Console App, I want to link to the above file. So, inside MyExecRefsLib folder (same folder where .sln file resides) I created a directory called "LibraryFiles" and placed both MathFuncsLib.lib file AND

CMake, Microsoft Visual Studio, and Monolithic Runtimes

为君一笑 提交于 2020-01-22 19:56:31
问题 I'm building a file using the CMake Build System and Microsoft's Visual C++ compiler. When I have CMake generate the visual studio project, the project contains the commandline to build a "Multi Threaded DLL" type of runtime -- one which depends on msvcrt.dll. For various reasons I'm not going into right now, I cannot depend on msvcrt. Is there a way to tell CMake to modify this option in it's construction process? 回答1: I use the following piece of code to link to the static CRT: if(MSVC) #