Hot answers tagged

20 votes
Accepted

Executing a shell command OS-independently

Just use system() While system() is often abused, here it is exactly what you want. It's a standard C function, so it's very ...
G. Sliepen's user avatar
  • 54.1k
15 votes
Accepted

Minesweeper C++

C++ Vs C As has been said in the comments, your code reads very much like it's been written in C. You're using C functions like printf instead of the more C++ <...
forsvarir's user avatar
  • 11.6k
8 votes
Accepted

Windows Keylogger

A few thoughts: 1. Fix your formatting Code that appears within a function scope should be indented by another set of spaces (tab): ...
πάντα ῥεῖ's user avatar
7 votes

Minesweeper C++

This makes me uneasy: ...
pm100's user avatar
  • 781
6 votes

Tic Tac Toe console game in C++ (w/graphic)

First, congratulations for writing a complete program. It's certainly the best way to learn, and the most gratifying. But I would also say that it's only the beginning: it's time to look back at your ...
papagaga's user avatar
  • 5,747
6 votes

Executing a shell command OS-independently

simplifications? You didn't describe the constraints this project is working under. If a python interpreter is available, you could readily achieve your goal by using "import graphviz". The ...
J_H's user avatar
  • 22.1k
5 votes

Win32 File API in VBA

This was a great find while looking for FileSeek capability from VBA. The only issue I had was when trying to go backwards from the current position. It turns out there's a simple trick to tell ...
dbmitch's user avatar
  • 295
5 votes
Accepted

Conway's Game of Life in Win32/GDI

Regarding 1.: Sure, you can just add a border to your field. That's trading space for code-simplicity, which is distinct from efficiency. Regarding 2.: Sure, there's no reason why you cannot just ...
Deduplicator's user avatar
  • 19.1k
5 votes
Accepted

Send command and get response from Windows CMD prompt silently

The question is very interesting, and obviously required some real time to implement. Just a few observations and suggestions: In the declaration of cmd_rsp() the variable size might be better named ...
pacmaninbw's user avatar
  • 23.8k
5 votes

Two-layer RAII to support a critical section

We can simplify that a lot. You are not really using RAII on the CriticalSection as you declare it in one place then initialize it in another. But ...
Martin York's user avatar
  • 94.6k
5 votes

A WinAPI C++ program for printing the master boot record of the hard drive

Idiomatic is relative. I guess it's a coding style you could find in older code-bases (and many winapi based applications are rather old), but you wouldn't write C++ like this today. Consider for ...
papagaga's user avatar
  • 5,747
5 votes
Accepted

Collecting all instances of an Office application (Excel, PowerPoint, Word)

...
Greedo's user avatar
  • 2,345
5 votes
Accepted

A C WinAPI program for showing the color of the screen pixel pointed to by mouse cursor with clipboard support

COLORREF color = GetPixel(GetDC(NULL), x, y); <- resource leak Each call to GetDC should be cleaned up by ...
Barmak Shemirani's user avatar
5 votes
Accepted

Proper way to send and receive buffer in Winsock

General Observations The code is mostly readable and except in one case maintainable. The exception may be a copy-and-paste error. Generally code isn't considered ready for review when it contains ...
pacmaninbw's user avatar
  • 23.8k
4 votes

File chunk buffer for Windows programs

This is a good exercise! I've actually had to implement buffering like this before, and I believe that most implementations of the standard library do something similar for file reading and writing by ...
user1118321's user avatar
  • 11.7k
4 votes
Accepted

C++ password generator with WinAPI clipboard function

Out Of Bounds Problem const int to = chars.size(); ... std::uniform_int_distribution<int> distr(from, to); uniform_int_distribution - Produces random ...
Mercury Dime's user avatar
4 votes

Minesweeper C++

This question is already quite old. Still there's a lot more to suggest for improvements. Here are some suggestions not mentioned yet. Don't use #define for ...
Sandro4912's user avatar
  • 3,056
4 votes

C++ upgradable RW lock implementation

The constructor of upgrade_lock never locks the mutex When constructing an upgrade_lock variable, the constructor sets ...
G. Sliepen's user avatar
  • 54.1k
4 votes
Accepted

A WinAPI C++ program for printing the master boot record of the hard drive

fourBitsToString and charToHex Both of these functions are basically reimplementations of existing features of the ...
hoffmale's user avatar
  • 6,468
4 votes
Accepted

Small C project: recording mouse/keyboard bot software

Reserved identifiers Identifiers starting with a single underscore followed by a capital letter are reserved by the Standard. You can't create any new name of that form at all in your code. (As you ...
alx - recommends codidact's user avatar
4 votes
Accepted

This program reads from serial port, Saves this to a text file, increments file name each time it is run

Welcome to Code Review, nice first question. Don't Panic, and always take a towel with you. General Observations This may be a copy and paste error, but the level of indentation is inconsistent. This ...
pacmaninbw's user avatar
  • 23.8k
4 votes
Accepted

A simple C WinAPI program for terminating processes via process image names

There is a subtle bug: Process32First(snapshot, &entry) already fills entry with the information about the first process in ...
Martin R's user avatar
  • 23.2k
4 votes

C++ winapi scale2x algorithm. Is it well implemented?

There are a couple of challenges to reviewing this: You don’t mention what version(s) of C++ you are targeting. I will assume C++20, because that’s the current standard. You don’t provide any example ...
indi's user avatar
  • 10.9k
4 votes
Accepted

A C++ WinAPI program for changing the process priority classes via PIDs

Some remarks. The error reporting is not consistent: Most error messages go to standard error (which is good), but some go to standard output. Most invalid input causes the program to exit with <...
Martin R's user avatar
  • 23.2k
3 votes
Accepted

Clipboard util made in WinAPI

This code hardly has any error handling. You never check return values of essential functions, such as GlobalLock, OpenClipboard ...
user7860670's user avatar
3 votes
Accepted

Convert FoxPro/dBase DATETIME field to Win32 SYSTEMTIME struct

meaningful identifier CONST DOUBLE dConvert = 2440587.5; Simonyi and Spolsky would tell you that this is not the original Apps Hungarian Notation. It does not ...
J_H's user avatar
  • 22.1k
3 votes

Safely handling memory allocation across DLL boundaries in Windows

The standard (and recommended) way to solve this is for each module to provide its own exported AllocMem and FreeMem functions (...
Cody Gray - on strike's user avatar
3 votes

File chunk buffer for Windows programs

Bug This line is not correct: ...
JS1's user avatar
  • 28.5k
3 votes

Asking Windows for real-time priority

Works as intended. But I get a thread priority of 15 rather than the expected 31 for a REALTIME_PRIORITY_CLASS? See SetThreadPriority. It seems that the ...
Paamand's user avatar
  • 131

Only top scored, non community-wiki answers of a minimum length are eligible