msvcrt

Python Windows `msvcrt.getch()` only detects every 3rd keypress?

允我心安 提交于 2019-11-28 10:30:53
My code is below: import msvcrt while True: if msvcrt.getch() == 'q': print "Q was pressed" elif msvcrt.getch() == 'x': sys.exit() else: print "Key Pressed:" + str(msvcrt.getch() This code is based on this question ; I was using it to acquaint myself with getch . I've noticed that it takes 3 pressing the key 3 times to output the text once. Why is this? I'm trying to use it as an event loop, and that's too much of a lag... Even if I type 3 different keys, it only outputs the 3rd keypress. How can I force it to go faster? Is there a better way to achieve what I'm trying to achieve? Thanks!

Why does _get_heap_handle equal to GetProcessHeap?

血红的双手。 提交于 2019-11-28 06:27:00
问题 According to this article, CRT uses separate heap (is it private heap ?), but this little example shows that CRT heap and Default heap are the same: HANDLE heaps[64]; DWORD heapCount = GetProcessHeaps(64, heaps); for (int i = 0; i<heapCount; i++) printf("heap %d : [0x%x]\n", i, heaps[i]); printf("crt heap[0x%x], default heap[0x%x]\n", _get_heap_handle(), GetProcessHeap()); In what cases GetProcessHeap and _get_heap_handle return different handles? // Compiled with VS2012 (Platform toolset

Windows malloc replacement (e.g., tcmalloc) and dynamic crt linking

断了今生、忘了曾经 提交于 2019-11-28 04:23:52
A C++ program that uses several DLLs and QT should be equipped with a malloc replacement (like tcmalloc ) for performance problems that can be verified to be caused by Windows malloc. With linux, there is no problem, but with windows, there are several approaches, and I find none of them appealing: 1. Put new malloc in lib and make sure to link it first (Other SO-question) This has the disadvantage, that for example strdup will still use the old malloc and a free may crash the program . 2. Remove malloc from the static libcrt library with lib.exe (Chrome) This is tested/used(?) for chrome

Does msvcrt uses a different heap for allocations since (vs2012/2010/2013)

 ̄綄美尐妖づ 提交于 2019-11-28 03:48:05
问题 I've read about that some time ago but am unable to locate the change to the crt on msdn or anywhere else in the web. I think the msvcrt has been changed in the VC++ release of VS2012 in a way that it no longer uses the private heap for allocations and uses process heap instead. Afaik it targeted issues of memory allocated in multiple libs which link statically against a crt and the subsequent release of memory in another lib where it was allocated. This is a major change in my view and I

How to execute some code before entering the main() routine in VC?

怎甘沉沦 提交于 2019-11-28 03:27:49
问题 I am reading Microsoft's CRT source code, and I can come up with the following code, where the function __initstdio1 will be executed before main() routine. The question is, how to execute some code before entering the main() routine in VC (not VC++ code)? #include <stdio.h> #pragma section(".CRT$XIC",long,read) int __cdecl __initstdio1(void); #define _CRTALLOC(x) __declspec(allocate(x)) _CRTALLOC(".CRT$XIC") static pinit = __initstdio1; int z = 1; int __cdecl __initstdio1(void) { z = 10;

WaitForSingleObject on a file handle?

旧巷老猫 提交于 2019-11-27 23:24:09
问题 What happens when you call WaitForSingleObject() on a handle you've created with CreateFile() or _get_osfhandle() ? For reasons not worth explaining I would like to use WaitForSingleObject() to wait on a HANDLE that I've created with _get_osfhandle(fd) , where fd comes from a regular call to _open() . Is this possible? I have tried it in practice, and on some machines it works as expected (the HANDLE is always in the signaled state because you can read more data from it), and on some machines

How do I get the file HANDLE from the fopen FILE structure?

萝らか妹 提交于 2019-11-27 22:43:50
The fopen function returns a pointer to a FILE structure, which should be considered an opaque value, without dealing with its content or meaning. On Windows, the C runtime is a wrapper of the Windows API, and the fopen function relies on the CreateFile function. The CreateFile function returns a HANDLE , which is used by other Windows API. Now, I need to use Windows API deep inside of a library that uses fopen and FILE* . So: is there a way to get the HANDLE from the FILE structure? As this is compiler specific, I mean on the MSVC runtime library. I understand that this would be an ugly, non

Visual C++ executable and missing MSVCR100d.dll

时间秒杀一切 提交于 2019-11-27 12:20:29
I know this has been asked in other places and answered, but I'm having issues with MS Visual Studio 2010. I've developed a C++ executable but if I run the Release version on a machine that doesn't have the VC++ runtime library (ie, msvcr100d.dll), I get the "program cannot start because msvcr100d.dll is missing from your computer" error. This is weird for two reasons: Why is it trying to link with the debug version of the redistributable? I tried applying this fix , setting the runtime library setting to /MT instead of /MD (multi-threaded DLL), but that only made the problem worse (if I

Visual studio 2015 run-time dependencies or how to get rid of Universal CRT?

会有一股神秘感。 提交于 2019-11-27 12:07:24
Compiled couple of .dll's using visual studio 2015, and tried to deploy on some older windows 7 / 64 bit. Tried also to guess which dll's are needed for application to start and copied MSVCP140.DLL & VCRUNTIME140.DLL - but application could not load vs2015 dll. Started to analyze what is wrong - and dependency walker showed dependencies from following dll's: API-MS-WIN-CRT-MATH-L1-1-0.DLL API-MS-WIN-CRT-HEAP-L1-1-0.DLL API-MS-WIN-CRT-CONVERT-L1-1-0.DLL API-MS-WIN-CRT-STRING-L1-1-0.DLL API-MS-WIN-CRT-STDIO-L1-1-0.DLL API-MS-WIN-CRT-RUNTIME-L1-1-0.DLL API-MS-WIN-CRT-FILESYSTEM-L1-1-0.DLL API-MS

How to Enforce C++ compiler to use specific CRT version?

给你一囗甜甜゛ 提交于 2019-11-27 09:05:49
I am using VS2008 for developing a COM dll which by default uses CRT version 9 but I am using TSF (Text service framework) that is not compatible with the new CRT. I think the solution is to use the compatible one so how can I specify the CRT version? I whole heartily join the recommendation not to manually change the CRT version you link against. If however, for some reason (which I cannot imagine) this is the right course of action for you, the way to do so is change the manifest for your project. First make sure a manifest is not generated on every build (on VS2005: Configuration properties