visual-c++

Using overlapped IO for console input?

佐手、 提交于 2020-01-20 05:03:25
问题 I'm attempting to use overlapped IO to read input from the console by opening CONIN$ with the FILE_FLAG_OVERLAPPED flag. However, ReadFile blocks when I use it, even with an OVERLAPPED parameter. I've read some posts reporting that this is a Windows 7 bug. I am using 7 so that could be possible. Here's the code I'm using: // Create a console window AllocConsole(); AttachConsole(GetProcessId(GetModuleHandle(NULL))); HANDLE overlappedConsoleIn = CreateFile(L"CONIN$", GENERIC_READ, FILE_SHARE

Weird MSC 8.0 error: “The value of ESP was not properly saved across a function call…”

只愿长相守 提交于 2020-01-18 21:32:52
问题 We recently attempted to break apart some of our Visual Studio projects into libraries, and everything seemed to compile and build fine in a test project with one of the library projects as a dependency. However, attempting to run the application gave us the following nasty run-time error message: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function pointer declared with a different calling convention. We

I cannot initializate WCHAR

*爱你&永不变心* 提交于 2020-01-17 16:38:28
问题 I need to make and WCHAR. But it wont work, and i always get an error: Error C2440 'initializing': cannot convert from 'const wchar_t [11]' to 'WCHAR *' StateError (active) E0144 a value of type "const wchar_t *" cannot be used to initialize an entity of type "WCHAR * My code: WCHAR *Testlooll = L"TEST"; 回答1: L"TEST" is a string literal of type const wchar_t[5] , which is an array of const characters (since the literal exists in read-only memory). You are trying to initialize a WCHAR* , which

C# - Method's type signature is not PInvoke compatible

岁酱吖の 提交于 2020-01-17 15:41:12
问题 I am trying to use the VC++ (2003) dll in C# (2010) When am calling the method of dll from c# am getting this error "Method's type signature is not PInvoke compatible" I am returning the structure from VC++ Code: struct SLFData { public: char ByLat[10]; char ByLong[10]; }; And I am marshalling in C# Code: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SLFData { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public char[] ByLat; [MarshalAs(UnmanagedType

What might cause SHChangeNotifyRegister to fail on Windows Mobile?

吃可爱长大的小学妹 提交于 2020-01-17 13:58:07
问题 I have the following code: SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry(); changeentry.pIdl = GetPidlFromFolderID(this.Handle, CSIDL.CSIDL_DESKTOP); changeentry.Recursively = true; uint notifyid = SHChangeNotifyRegister( this.Handle, SHCNF.SHCNF_PATHA , SHCNE.SHCNE_ALLEVENTS, WM_SHNOTIFY, 1, ref changeentry); My code is crashing at the SHChangeNotifyRegister. I am trying to register a form for file change notification in Windows Mobile. I think I may be passing incorrect

What might cause SHChangeNotifyRegister to fail on Windows Mobile?

随声附和 提交于 2020-01-17 13:57:12
问题 I have the following code: SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry(); changeentry.pIdl = GetPidlFromFolderID(this.Handle, CSIDL.CSIDL_DESKTOP); changeentry.Recursively = true; uint notifyid = SHChangeNotifyRegister( this.Handle, SHCNF.SHCNF_PATHA , SHCNE.SHCNE_ALLEVENTS, WM_SHNOTIFY, 1, ref changeentry); My code is crashing at the SHChangeNotifyRegister. I am trying to register a form for file change notification in Windows Mobile. I think I may be passing incorrect

ApplicationVerifier is not detecting handle leaks, what do I do?

≯℡__Kan透↙ 提交于 2020-01-17 13:44:13
问题 I did select the executable correctly, because I can get it to respond to certain things I do. But I can't get ApplicationVerifier to properly detect a handle leak. Here is an example: int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HANDLE hFile = CreateFile(_T("C:\\test.txt"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); return 0; } ApplicationVerifier doesn't detect this. What can I do to detect the above problem? 回答1: Is your code

ApplicationVerifier is not detecting handle leaks, what do I do?

安稳与你 提交于 2020-01-17 13:43:04
问题 I did select the executable correctly, because I can get it to respond to certain things I do. But I can't get ApplicationVerifier to properly detect a handle leak. Here is an example: int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HANDLE hFile = CreateFile(_T("C:\\test.txt"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); return 0; } ApplicationVerifier doesn't detect this. What can I do to detect the above problem? 回答1: Is your code

Auto-vectorization of loop containing comparisons

不羁的心 提交于 2020-01-17 07:43:09
问题 I'm trying to use the Visual C++ 2013 auto-vectorizer to make the following loop vectorized ( /arch:AVX2 ) but the compiler refuses and gives the following message: info C5002: loop not vectorized due to reason '1100' This reason code means Loop contains control flow—for example, "if" or "?". I have tried to split the comparisons and the final assignment into a separate loop but that seems inefficient when there are intrinsics available for performing comparisons on floating point values. Why

opencv structured forest edge detection and findcontours

≯℡__Kan透↙ 提交于 2020-01-17 06:38:57
问题 I am trying to use opencv via visual c++ to extract contours of an image. I was able to do that using the opencv tutorial for findcontours. findcontours works in two steps Detect edges using canny edge detector. Feed the output of canny to findcontours. I want to try out the same with 'Structured Forest Edge Detection' (Zitnick et al). I am able to extract the edges and display them, but when I try to feed the output to findcontours. I am getting a 'cv::Exception at memory location 0x0020EE9C