[Memorandum] technical notes.

Source: Internet
Author: User
Tags filetime

[Original statement] It basically refers to some technical notes recorded through msdn, Web search, and so on during my usual coding. In essence, these contents are not original and innovative, but they are not easy to remember because of their complexity. These entries are listed here. They are dominated by C ++ and have no central idea. They are only used for memo and query.

(1) standardized writing method for detecting valid input (char *):

Char text []; // The text to be checked

If (strlen (text )! = Desiredlength | strspns (text, "1234567890") <desiredlength)

Return false;

Desiredlength indicates the expected length of the input content, and "1234567890" indicates the combination of valid character sets.

(2) features of strncpy (char * DEST, const char * Source, size_t count:

* When count <= strlen (source) is used, null-Terminator is not automatically added to the backend. Only the copy character action is executed.

* When count> strlen (source) is used, 0 is added after it until the number of characters copied to the target buffer reaches count.

(3) alloca (size_t size) is used to allocate space on the stack (no corresponding release function is required ).

(4) convert the hexadecimal string to an integer: strtol.

(5) adjustwindowrectex function: the window rectangle is measured based on the customer rectangle.

A customer rectangle is provided. Based on the window style and extended style, whether there is menu or other information, the window rectangle that can accommodate the customer rectangle is returned. The window rectangle can then be passed to the createcustomwex function.

(6) If a virtual function is called in the constructor (destructor) function, the function defined by its own type is called. (The meaning of this sentence is not accurate. I forget what I originally wrote)

(7) time span obtained by MFC.

Ctime time1 (2008, 8, 8, 0, 0, 0 );

Ctime time2 = ctime: getcurrenttime ();

Ctimespan timespan = time2-time1;

Cstring strtext;

Strtext. Format (_ T ("% d days % d hours"), timespan. getdays (), timespan. gethours ());

(8) add an etching line in the dialog box:

Add the image control and change the color attribute to etched.

Adjust the height of the ComboBox drop-down box: Select ComboBox and click the drop-down button to drop down the size box. Note: If you use the createwindow function to create a drop-down box, the specified height should not be the text box height, but contain the total height of the text box + drop-down list box.

(9) flashwindow/flash1_wex: flashing window and taskbar buttons.

(10) messagebeep (mb_iconexclamation): sends a system-defined warning.

(11) Draw a standard control on the user interface (for example, the drag triangle pattern in the lower right corner of a button): drawcontrolframe.

Draw the rectangular edge of a three-dimensional appearance: drawedge;

Draw the focus rectangle: drawfocusrect.

(12) If break is used in the for loop to end the loop, the third clause is not executed. For example:

For (I = 0; I <1000; I ++) break;

Printf ("I = % d \ n", I); // output I = 0;

(13) struct is a class in which the default member function is public.

(14) hresult cofiletimenow (filetime * lpft): The current time is returned as the filetime structure.

(15) iactivedesktop: setwallpaper: Set the desktop wallpaper.

(16) Control Service Status: controlservice.

(17) _ beginthread and _ endthread are C Runtime library functions;

Createthread is a Win32 API. By default, the stack of a thread is 1 MB.

Exitthread can provide a thread exit code, which is obtained using getexitcodethread.

(18) enum1_tops: enumerate the desktop of the workstation where the current process is located.

(19) setprocesswindowstation: set the process's window workstation.

Windowstation workstation includes the following resources: all desktops, clipboard, and atomic weight (what is this ?)

(20) SID: security identifier, a variable-length struct that uniquely identifies a user or group.

Access Control: Permission control (not supported by winme, and 98 ).

Securable object: an object that can have a security descriptor.

Security Descriptor: security descriptor, associated with a securable object.

Security descriptors: includes

SIDS (master, group ),

DACL: permissions for specific users and groups (allow/Deny)

SACL :( what is this ?)

A group of control bits: Indicate the meaning of itself or its members.

Securable objects: includes all named Windows objects. Some unnamed objects (such as processes and threads ). For most objects, you can specify security descriptors in the APIs that create them, such as files, directories, named/anonymous pipelines, processes, threads, file ing, access tokens, system Management Objects (workstation, desktop), registry keys, system services, network sharing, process synchronization objects (events, mutexes, sepaphors, scheduling (job objects), and directory service objects.

Access Token: permission information of a logon session.

(21) obtain system information (number of CPUs, CPU type): getsysteminfo.

(22) play wav files: playsound (_ T ("....wav"), null, snd_filetime | snd_async );

(23) create a shortcut: shcreateshortcutex.

Ishelllink interface: create, modify, and parse shortcuts.

(24) obtain the path of a specific folder: shgetfolderpathandsubdir.

(25) The measurement string in MFC: CDC: getoutputtextextent.

(26) redraw menu: drawmenubar (hwnd ).

(27) Get the font size of the dialog box: getdialogbaseunits.

(28) Let the ComboBox implement automatic completion (similar to the IE Address Bar): shautocomplete (note that you need to call the COM Initialization function first)
Hwnd hcombobox = getdlgitem (hdlg, idc_combo_test );
Hwnd hedit = find1_wex (hcombobox, null, _ T ("edit"), null );
Shautocomplete (hedit, shacf_default | shacf_filesystem );

(29) animation effect (for example, gradient) When closing the window: animatewindow.

(30) Two easier functions than CreateProcess: winexec and shellexec.

(31) add, modify, and delete a tray (tray) icon: shell_policyicon.

(To be continued)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.