Stuff I've Learned:


Win32:
  • To use wmain in place of main in a unicode console app, and build from the command line without error LNK2001, set /ENTRY:wmainCRTStartup linker arg using /link (to tell compiler to pass the following arg to the linker). Thanks to Todd MacCullouch for motivating me to figure this out.
  • Win32 SDK docs for several LM functions erroneously refer to return value "NERR_SUCCESS"; actual value is "NERR_Success" (case-sensitive).
  • To fix named pipe problem where server wakes up and reads 0 bytes, call PeekNamedPipe() first until there is >0 bytes in the buffer. -Thanks to Markus Fischer
  • In Win32 console apps, atexit() is not enough...you need to call SetConsoleCtrlHandler().
  • In MFC apps, #include <lm.h> must occur AFTER local #includes or compiler acts as if it was never included!
  • When adding a Rich Edit control to an MFC app, you need to call AfxInitRichEdit() when initializing the app.
  • Win32's ExitProcess() causes output sent to stdout to disappear when the process is being run by perl's backtick operator.
  • Must call CoInitialize() in a worker thread before making any COM calls (duh).
  • When compiling an app containing both mfc and non-mfc modules, build the mfc one first to avoid lnk2005 errors.
  • Use ShowDialog instead of Show to return result from Windows Form in VS.Net; set DialogResult property in form instead of calling Close to set value.
  • strftime() modifies its input buffer so you must get all your formatted strings in a single call.
  • .net registry functions are in Microsoft.Win32 namespace (not system).
  • c# structs can have constructors (and are almost required for initialization).
  • arrays are a pain in the butt in c#
  • if NetMessageBufferSend's 'from' arg is non-null, it must be a valid domain account name or the function returns error 2273.
  • .net framework stores ADSI objects in System.DirectoryServices (add ref to project).
  • to exit from anywhere in a c# console app, use Environment.Exit(int).
  • to add .ico resources to an imagelist in a vstudio c# project, set their 'build action' property to 'embedded resource' and use the following syntax: ilst.Images.Add((Image) new Bitmap(GetType(),"my.ico")); (-thanks to Ed Sutton)
  • in vs.net, upon completion of a drag/drop operation, when source is a treeview control, the treeview resets its selected node to the root node when reclaiming focus.
  • to get selected row from a windows.forms.datagrid control use the following technique (c#):
     System.Windows.Forms.DataGridCell selectedCell = myDataGrid.CurrentCell;
     string s = myDataGrid[selectedCell.RowNumber, 0].ToString();      // gets 0th field in row
  • if NetMessageBufferSend fails with error 2273, check to see if messenger service is running...XP disables this service by default.
  • if SmtpMail.Send throws exception, must use fully qualified filespec for attachments.
  • to force odbc connection to use named pipes protocol, "network=dbnmpntw" in connection string.
  • to remove .net form-based app from taskmgr's alt-tab list, set the form's FormBorderStyle to FixedToolWindow.

  • C++:

  • to convert stl string to traditional c str (const char *), use string.c_str() member function.

  • Perl:

  • perl's open() fails when passed a filespec containing quotes. Even if the filespec has embedded spaces, do NOT use quotes when passing to open(). -thanks to Jenda Krynicky
  • perl (win32)'s ternary operator requires NO PARENTHESES.
  • to assign a value to a (scalar) Class::struct member, use ctor syntax (parentheses) instead of an equal sign.
  • the Win32::EventLog raw EventID value must be ANDed with value 0xffff to correspond with the expected EventViewer display (I don't know why).
  • If perl won't match a valid regex and it's a filespec, try using unix path delimiter('/' instead of '\') in your filespecs.
  • '*' char in regex matches 0 or more instances of THE PRECEEDING CHARACTER. So for instance, to match lines beginning with chars '/', '-' or '?' use the following: /^[-\/?].*/ (notice '.' preceeding '*').

  • VMS:

  • VAX/VMS fflush() doesn't; to fix, (1) open file with shared access as follows: fopen(fp,"a","shr=get"); and (2) follow fflush call with undocumented fsync() as follows: fsync(fileno(fp));

  • Windows 2000 & 2003 System Administration:

  • Quick Launch items are stored as .lnk files in this folder:
    "Documents and Settings\%username%\Application Data\Microsoft\Internet Explorer\Quick Launch"
  • The W2K task scheduler service keeps a log: %systemroot%\schedlgu.txt
  • W2K creates registry entries for all installed hotfixes in the location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates
  • To run perlscript client scripts, NOT in html or asp, use the file extension .wsf
  • If you get error 'operation is not allowed on this special group' trying to delete a user from a group, the group may be set as 'primary' in user account. Set another group as primary to fix.
  • If changing time format (regional settings) programmatically has lingering problems (vbs script appeared to properly change format but fdm app popped up error) try setting REG_SZ entries iTime and iTLZero to "1".
  • If scheduled job doesn't run and status is 'could not start', change the account password stupid.
  • To fix dropped session state in web apps, set 'max worker processes' to 1 in IIS application pool.

  • Windows NT System Administration:

  • To install the ftp service on NT Workstation, you must add the network service "Microsoft Peer Web Server."

  • SqlServer:

  • You can perform interactive SQL queries from a command prompt using ISQL.
  • IDENTITY column property is lost when migrating SqlServer database from 6.5 to 7.0.
  • When modifying a table in a SqlServer 6.5 database, if you replace the table, repopulate it and rename it to the original name, this will break any stored procedures which reference that table (probably the compiled sp uses internal table ID instead of table name), so to fix you must resave the stored procedures.
  • Problem: switching ODBC DSN config server from Sql65 machine to Sql2000 machine broke service which used DSN to connect to database. (DSN test connection worked, interactive perl & cpp apps worked.) Fix: changed service account from localsystem to domain admin; apparently Sql2000 is more strict about security.
  • To use a tablename which contains embedded spaces in T-SQL, put square brackets around the tablename.
  • IRiver iHP-140 MP3 Player:

  • To use linux m3u playlists you need to replace all '/' chars with '\', and terminate lines with CR/LF pairs.
  • Dell

  • To install array manager from dell server management cd ver 4.5, use command line:
    F:\OpenManage\windows\SystemsManagement\sysmgmt.msi ENABLEAM=YES