Archive for the ‘Developer’s Cookbook’ Category

How to run some Windows Update exe files

Sunday, April 12, 2009

for %%i in (dir *.exe) do %%i /passive /norestart

Test: one bit in C++ struct

Friday, August 1, 2008

Test program: typedef struct{ int value:1; } test_struct; test_struct a; a.value = 1; std::cout << a.value; Out: -1 More extended version: typedef struct{ union{ byte m_byte; struct{ byte m_bit0:1; byte m_bit1:1; byte m_bit2:1; byte m_bit3:1; byte m_bit4:1; byte m_bit5:1; byte m_bit6:1; byte m_bit7:1; }; }; bool check_bit(byte index){ return (m_byte | index) != 0; } } test_struct_ex; test_struct_ex b; b.m_byte = 2; std::cout << (b.check_bit(1) ? "true" : "false"); OUT: true