msvcrt

Right arrow symbol causing abrupt end of fread?

百般思念 提交于 2019-12-06 08:33:40
问题 I am attempting to write a bittorrent client. In order to parse the file etc. I need to read a torrent file into memory. I have noticed that fread is not reading the entire file into my buffer. After further investigation it appears that whenever the symbol shown below is encountered in the file, fread stops reading the file. Calling the feof function on the FILE* pointer returns 16 indicating that the end of file has been reached. This occurs no matter where the symbol is placed. Can

How to detect key press when the console window has lost focus

心不动则不痛 提交于 2019-12-06 07:05:42
问题 My application sends a mouse click to an area of the screen outside my console window using win32api.mouse_event . This causes my window to lose focus so I can't detect key presses using msvcrt.kbhit. My question is, how to implement something like this with the console window not being visible/active? EDIT: Here is example code. This is just a basic console version. If the console disappears, set it so that it stays on top. Once it clicks outside of the console (100,100), pressing the Esc

MinGW MSYS, MSVCRT, and the TZ environment variable

寵の児 提交于 2019-12-05 17:27:41
In short, how to make both MSVCRT and MinGW MSYS share the TZ environment variable without conflicts? Or, how to make both support timezones without conflicts? Further information In order to have date command of MSYS displaying correct local time, and because MSYS itself uses its own C runtime instead of MSVCRT, I have set TZ environment variable according to GNU C library documentation : export TZ="BRT+3BRST,M10.3.0/0,M2.3.0/0" Unfortunately, this conflicts with Microsoft C runtime specs , which dictates for the DST name part: If daylight saving time is never in effect in the locality, set

Assertion error in CRT calling _osfile() in VS 2008?

本小妞迷上赌 提交于 2019-12-05 09:21:59
I have a C++ code base that has been working for a long time. The code base was a legacy VS 2003 set of projects that I recently migrated to VS 2008. The migration seemed to be successful in that the resulting program built, and run. I reinstalled my OS and all applications on a fresh drive, and now when I attempt to debug the program within the debugger, I receive an assertion error inside the CRT's chsize (really, _chsize_s ). Specifically (cropped to essentials, ignoring safety checks): FILE * testfile = fopen("P:\\_Dan\\local\\foogoo.txt", "w"); int filehandle = fileno(testfile); chsize

Working around fls limitations with too many statically linked CRTs?

99封情书 提交于 2019-12-05 08:35:38
When loading external DLLs (not under our control) via LoadLibrary, we're hitting a problem where the statically linked CRT in those DLLs are failing to allocate fiber-local storage. This is similar to mskb 193462 , except that this is FLS and there's only 128 of them. Are there any useful ways to work around the problem? The CRT is using GetProcAddress to find FlsAlloc anyway (since that apparently never existed in XP), so does it even really need it? (This is on Vista, where FlsAlloc actually exists; the DLLs appear to be using MSVC8) There is frankly no solution here, short of loading less

list available platform toolsets

喜夏-厌秋 提交于 2019-12-05 07:18:02
Is there any method to list platform toolsets available in VS2012? I mean a list that might contain v90, v100, v110, v110_xp and any externally provided platform toolset. Alternatively (should that be easier): is there a way to check if given platform toolset is installed or not? Here is a console app utility (in C#) that dumps the list of toolset (for each available configuration). You need to add a reference to Microsoft.Build to be able to compile. Note the proper list of toolset is supposed to depend on the project to build: using System; using System.Collections.Generic; using System.IO;

How can fopen_s be more safe than fopen?

别等时光非礼了梦想. 提交于 2019-12-04 23:51:43
I'm working on legacy code for Windows platform. When I compile the code in VS2013 , it give following warning: error C4996: ' fopen ': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details." And it will also give samiliar warning for sprintf . I understand sprintf_s is more safe than sprintf because of buffer overflow. But how can be fopen_s be more safe than fopen , there is no chance of buffer overflow because fopen doesn't accept an buffer. Can anyone provide an case fopen is unsafe, and

In which cases is the dynamic CRT not already initialized on call to user supplied DllMain?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 23:46:47
问题 Preamble: This question is specifically concerned with, and only with, the behavior of the dynamic CRT used through /MD . It does not question the validity of any other recommendations wrt. DllMain . As we've been told: (ref: Dynamic-Link Library Best Practices, MSDN, May 17, 2006) You should never perform the following tasks from within DllMain: ... Use the memory management function from the dynamic C Run-Time (CRT). If the CRT DLL is not initialized, calls to these functions can cause the

.crt section? What does this warning mean?

北城以北 提交于 2019-12-04 19:23:21
问题 I've got this warning recently (VC++ 2010) warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators I'm assuming this is the Critical Section. It's been a while since my Operating Systems course, so I can't really figure out what this means. If I remember right, the Critical Section works with shared resources. So how is this warning related and what does it mean exactly? 回答1: No, CRT = C Run Time. It is support library that any program needs to get the

How to not link against msvcr100.dll?

Deadly 提交于 2019-12-04 19:22:50
I am compiling project in Visual Studio 10, compiled executable runs fine on win 7 but it doesnt works on win xp because of missing msvcrt100.dll. I tried to use "/NOTDEFAULTLIB" but it also removes some other external libs that i use. Is there way to not link against latest Microsoft runtime library ? Thanks in advance. To not link against the DLL you must link against the runtime statically. To do this, go to C/C++ Properties -> Code Generation and under Runtime Library select Multi-threaded (/MT) or Multi-threaded Debug (/MTd) from the drop-down. Note, once you're using a static runtime