Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

All Snippets
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Top 100 Snippets >> Windows
Top 100 Windows Snippets
These snippet titles reflect my cut at the most common functions a programmer needs to create Windows applications. You might find 40-50 of these in any one application but you're very unlikely to find them all in any most programs.

I find that my opinion continues to shift on about 10%-20% of the list, so don't be surprised to find the list changing - or growing as I consider the list in more detail.

You can view the snippets online at this site or download my freeware gbCodeLib code librarian, which has the source code for all of these. It contains snippets and mini-tutorials for several languages such as VB, VB.net, VBA, JavaScript, Perl, Java, and HTML.

Applications
1. Associate an extension with an application
2. Create a shortcut to an application
3. Open a Color dialog
4. Open a File dialog
5. Open a Folder dialog
6. Open a Font dialog
7. Put app icon in the system tray
8. Put app in the Explorer context menu
9. Put app in the SendTo context menu
10. Start a new application and wait for it to finish
11. Start an application when Windows starts up
12. Test whether the application is running within the IDE
13. Maintain MRU file (most recent updated files)
14. Read/write INI files
15. Create context menus
16. Resize controls when form resizes

Arrays
17. Cycle througn an array
18. Randomly shuffle an array
19. Remove an element of an array (by content or by position)
20. Search an array

Clipboard
21. Copy or retrieve text and images from the clipboard

Controls
22. Automatically highlight textbox content on focus
23. Capture any key (Enter, TAB, arrow keys, home/end, F-keys, ...)
24. Forces lower/upper case on text input
25. Richtextbox manipulation (word wrap, find and replace, TAB control, ...)
26. Toolbar manipulation (customize, dropdowns, images, sync with menus, ...)
27. Statusbar manipulation

Date-Time
28. Compute elapsed time between 2 dates
29. Compute elapsed time between 2 events (ms accuracy)
30. Display time in multiple formats

Files
31. Create valid full pathname from folder and file names
32. Extract file name from a full path
33. Determine if a file exists
34. Get file properties (size/date/attributes)
35. Delete a file to the recycle bin
36. Backup/restore a file

File - Text
37. Read file one line at a time or all at once
38. View content

File - Binary
39. Read/write data at a specific location
40. Read entire file at once
41. View contents in hex or binary-stripped format

Folders/Drives
42. Determine if a file exists
43. Delete a folder and its subfolders
44. Get list of dirve letters
45. Get type of drive
46. Open DOS windows at a specific folder
47. Open a Window at a specific folder
48. Open Windows Explorer at a specific folder
49. Create a fll path of folders

Forms
50. Center a form
51. Keep form on top
52. Set min/max size of form
53. Add a splitter (vertical/horizontal)
54. Unload all forms

Graphics
55. Convert between Long, RGB, VB, and web colors
56. Get image size without reading entire file (JPG/GIF/BMP)
57. Get screen resolution
58. Generate a gradient fill
59. Overlay an image with transparency control
60. Read/write/display/convert images (JPG/GIF/BMP)
61. Resize and image, keeping aspect ratio
62. Capture the screen or any part of the screen
63. Set wallpaper - center/stretch/tile

Internet
64. Check for Internet connection
65. Create URL shortcut
66. Create web page (HTML) from code
67. Download text/binary file, with progress indicator
68. Upload text/binary file, with progress indicator
69. Get remote file information (size/date0
70. Open a web page in a browser
71. Send email using default email application
72. Update file via FTP

Math
73. Create random integer within specified range
74. Round number to specified number of decimals

Multimedia
75, Play CD
76. Play sound or video file (.wav, .mp3, ..mid, avi, .mpg)
77. Record sound or video

Navigation
78. List all files and folders beneath a specified full path

Printing
79. Print images (positioned, scaled, or tiled)
80. Print preview
81. Color text printing
82. Send page eject to the printer
83. Print justified text (left/right)

Registry
84. Clear application setting from registry
85. Write/edit application settings
86. Write/edit/delete anywhere in the registry

Security
87. Calculate checksum
88. Encrypt/decrypt a file/string (with or without a password)
89. Disable Ctrl-Alt-Del

Sort
90. Bubble sort
91. QuickSort

Strings
92. Convert strings to upper/lower case
93. Find/replace a string within a string
94. Split string into an array based on delimeters
95. Find text between two strings

System
96. Get computer name
97. Get user name
98. Get name of special folders (Windows, System, SendTo, Startup,
99. Get Windows version
100. Reboot / restart / logoff system