Code Library

Free Source Code and Program Tips

How to hook the file related event

How to hook the file related event? It depends on what you need to do when such an event takes places. If what you just want to be notified, FindFirstChangeNotification and ReadDirectoryChanges are enough. If you need to intercept adn affect the operation somehow, I have heard it can be done with a kenerl-level driver(Filesystem [...]

CWnd::IsIconic BOOL IsIconic( ) const; Return Value Nonzero if CWnd is minimized; otherwise 0. Remarks Specifies whether CWnd is minimized (iconic). Example // This code, normally emitted by the AppWizard for a dialog-based // project for the dialog’s WM_PAINT handler, runs only if the // window is iconic. The window erase the icon’s area, then [...]

When you develop some admin utility, which will need the administrator privilege to configures some H/W connected ove LAN, etc. And you will found that the application is running propertyly in XP just by a double click of the mouse, where as in VISTA if you run it as Administrator then only running. So, how [...]

How to read the sectors of physical drive under win32? The API ReadFile is most useful function, and with it, you can read the physical sectors directly. Here is a sample function, BOOL ReadSectors(…) BOOL ReadSectors( BYTE bDrive, //drive index DWORD dwStartSector, //start sector WORD wSectors, //sectors number LPBYTE lpSectBuff) {  if (bDrive == 0) [...]

How to get a fixed code for serial number(2)

I have post an article about “How to get a fixed code for serial number” at http://www.ucosoft.com/archives/51.html. In that article, I suggest you try WMI class to retrieve  some hardware ID. But there is some limitation of this method. The WMI redist package is not always available on user’s system, for example, Windows NT4 and Windows [...]

How to Get the Primary Domain name

In gina, the system will list the domain name of the current system. How to get the primary domain name in your program? From the released the Windows2000 and NT source code, you can get the code of gina. It locate on \win2k\private\windows\gina\winlogon\usrpro.c. Here is the code:

How to get the local DNS server record

If you don’t have Iphlpapi.lib installed, you can retrieve the local DNS server in the following way. The main step is load “Iphlpapi.dll” with ::LoadLibary method and call ::GetProcAddress to get the “GetNetworkParams”. Here is the full source:

How to retrieve the authenticode information

Chinese verion author: Quaful@newsmth.net. When an ActiveX will be installed in IE, the authenticode information will be showed out. And how to get the information by programming? In microsoft KB323809: HOWTO: Get Information from Authenticode Signed Executables, there is a full example code. But it’s not very easy to use in your program directly. So [...]

How to read the graphics card RAM capacity

When you want to get the RAM capacity of the graphics card installed on the computer, It’s more simple to use WMI class. You can give a look at the AdapterRAM attribute of Win32_VideoController. The Win32_VideoController WMI class represents the capabilities and management capacity of the video controller. AdapterRAM is one of its attibute: AdapterRAM [...]

How to get a fixed code for serial number

We often look for some fixed serial numbers as an universal id. Usually we can use WMI class to retrieve  some hardware ID as following: Win32_BaseBoard Win32_Processor: ProcessorId Win32_BIOS: SerialNumber, ReleaseDate Win32_MotherboardDevice: InstallDate Win32_DiskDrive We can refer to MSDN WMI C++ Application Examples for some VC++ samples for the usage.But not all of the above WMI [...]