Free Source Code and Program Tips
Posts tagged How-to
How to Get the Primary Domain name
Jan 3rd
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
Jan 2nd
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
Dec 31st
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
Dec 18th
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
Dec 1st
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
A powerful math function parser(zz)
Nov 29th
by Andreas Jdger The inspiration to write this code was to have an easy-to-use parser for functions given as string. You have a string like cos(x)-7*x/(1+x) and you want to compute some values, maybe for displaying the graph of the function. You can write code like this: CFunction* fkt = CFunction::Parse(“cos(x)-7*x/(1+x)”); long double y =
A good article about Using auto_ptr Effectively
Nov 25th
Here is only a short introduction of the article, if you are interested, please goto the author’s website for the full text. Most people have heard of the standard auto_ptr smart pointer facility, but not everyone uses it daily. That’s a shame, because it turns out that auto_ptr neatly solves common C++ design and coding
File processing — Remove the first column of each line
Nov 24th
Question I have a text file with a lot of lines, and in each line, there are several columns divided by space character, but the number of columns in each line varies. For example, here is a sample ——————– abc 123 234 456 bsc 3 5 7 9 10 123 yyt 23 ——————– I want
Write and read binary data in VARIANT
Nov 22nd
We offen need to store some binary data in the mdb database, thus we have to transefer the data by VARIANT structure.But how to read from binary data from VARIANT or write to? Here is a solution by safe array of VARRIANT.