Dave Horner's Website - Yet another perspective on things...
53 guests
Rough Hits : 4708649
how did u find my site?

nature of God

Code is like poetry; most of it shouldn't have been written.
\begin{bmatrix} 1 & 0 & \ldots & 0 \\ 0 & 1 & 0 & \vdots \\ \vdots & 0 & \ddots & 0\\ 0 & \ldots & 0 & 1_{n} \end{bmatrix}

# Windows Programming

Sunday, 27 March 2005 01:00
System Error Codes (Windows) - whats that GetLastError() mean?

## ODBC and DSN

I have noticed that sometimes the "ODBC Data Source Administrator" doesn't show system DSNs that exist in the system. As in, sometimes a custom program will be able to connect, but other tools can't see/use that DSN. I have found that it is the result of missing entries in the registry. If you look in HKLM\SOFTWARE\ODBC\ODBC.INI you will see all your DSN info as hives underneath. HKLM\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources show also have an entry for each one of those DSN entries. However, for some unknown reason, the entries don't exist. Fix em in regedit and it'll show up and work again!
Hey, Scripting Guy! Can I Create and Delete a DSN Using a Script?
How to Create ODBC DSN on multiple SQL server machines
Install and Configure the MS ODBC Driver on Debian - sqlncli11 package from MS and the unixODBC 2.3.1 Perl DBD::ODBC with Unicode support.

## Reading proxy settings from IE

There have been times when I'm using the libcurl library or even my own socket code and I need to get the proxy information from the OS.  This little snippet can be used to pull the proxy information from the registry.  (The proxy information is set in the IE connections tab)
Use this function to grab the proxy value and pass it on to libcurl or whatever.
#ifdef WIN32
#include <tchar.h> // for the unicode _T() macros
char *GetMSRegistryProxy(char *dest, int len)
{
DWORD type, bufsize=20;
char buf[20];
HKEY subkey;
long ret;

dest[0]='\0';
ret = RegOpenKeyEx(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
0,KEY_QUERY_VALUE, &subkey);
if(ret == ERROR_SUCCESS) {
ret = RegQueryValueEx(subkey, _T("ProxyEnable"), NULL, &type, (LPBYTE)buf, &bufsize);
if(ret == ERROR_SUCCESS) {
if(*buf!=0) {
ret = RegQueryValueEx(subkey, _T("ProxyServer"), NULL, &type, (LPBYTE)dest, (LPDWORD)&len);
}
}
RegCloseKey( subkey );
}
return dest;
}
#endif

## curl for windows

peters/curl-for-windows - git clone https://github.com/peters/curl-for-windows.git;git submodule update --init --recursive;python configure.py

## ActiveX controls

I've done a lot of COM/ActiveX development over the years.  This is just a little information I found handy when dealing with ActiveX controls.

All WebBrowser Interfaces
This interface is used if you want to find things like when the Navigate2 is fired or when the window is closing.
DWebBrowserEvents2 Interface

If you want events for the page itself, you have to sink up with the HTMLWindowEvents interface.
HTMLWindowEvents Dispinterface

In order to establish the event sink, you need to:
1) Get the top-level IWebBrowser2 reference from your activeX control
Q257717 HOWTO: Retrieve Top-Level IWebBrowser2 Interface from ActiveX
2) Follow the instructions in the following article to establish the sink:
HOWTO: Create a Sink Interface in MFC-Based COM Client
Note: When you call AfxConnectionAdvise, pass in the the IWebBrowser2 reference for the first parameter.

Here is some additional information specific to handling events from an ActiveX control
Handling HTML Element Events
Q167230 HOWTO: Detect When Internet Explorer Holds Controls and Pages in Memory

WTL Developer Guide
AtlServer
PRB: Error C2787 When Building a Project Using ATL 3.0
Windows Template Library - Wikipedia, the free encyclopedia
SourceForge.net: Windows Template Library (WTL)

## Platform SDK / Windows SDK

The windows SDK now supersedes the platform SDK. It is a NO-NO to have both the Windows SDK and the platform SDK installed. There are some other gotchas too...
Re: missing winable.h - MSDN Forums
Download details: Microsoft Windows 7 SDK - The Windows SDK for Windows 7 and .NET Framework 3.5 SP1 provides documentation, samples, header files, libraries, and tools designed to help you develop Windows applications using both native (Win32®) and managed (.NET Framework) technologies.

## Device Development Kit (DDK)

To build within the windows DDK, create two shortcuts with the following targets. (This assumes WIN2003 SP1 DDK)
%windir%\system32\cmd.exe /k C:\WINDDK\3790.1830\bin\setenv.bat C:\WINDDK\3790.1830 checked
%windir%\system32\cmd.exe /k C:\WINDDK\3790.1830\bin\setenv.bat C:\WINDDK\3790.1830 free
The free and checked env. correspond to release/debug as in normal development environments. To build the samples and code, you'll need to run the command "build" from the cmd.

## Windows Driver Development

Windows Driver Development (Windows Drivers)
Components of a Driver Package (Windows Drivers)
Installable Driver Reference (Windows) - dlls with the good ole DriverProc.
Audio Device Technologies for Windows
Windows Device Console (DevCon) Tool sample in C++ for Visual Studio 2013 DevCon Examples (Windows Drivers)
Windows Microsoft Virtual Audio Device Driver Sample in C++ for Visual Studio 2013
Driving One's Own Audio Device | Linux Journal
OSR's ntdev List: Installing msvad using Devcon
How Driver Installation Works - driver writing != bus driving - Site Home - MSDN Blogs
Analyzing the Installation of UMDF and KMDF 1.5 drivers - driver writing != bus driving - Site Home - MSDN Blogs

When developing with sockets, I've found that order and multiple definitions get hairy. Apparently, you can't include winsock.h and winsock2.h at the same time. Tracking down these issues is VERY hard.
If you have errors like "'AF_IPX' : macro redefinition" or other nonsense like "'fopen' : is not a member of 'global namespace''" It could be winsock issues.
It looks like the suggested practice is to include winsock before windows.h otherwise you'll get nonsense.
#ifdef WIN32
#include <winsock2.h>
#include <Windows.h>
#endif

## Remote desktop notes

There is a lot of good information available from the function GetSystemMetrics, like screen size, if it's a remote desktop session, or the number of displays. Useful.
GetSystemMetrics Function (Windows)
Optimizing Visual Studio 2010 and WPF applications for Remote Desktop - WPF Performance and .NET Framework Client Profile - Site Home - MSDN Blogs

## win32 sidenotes

The Old New Thing : BOOL vs. VARIANT_BOOL vs. BOOLEAN vs. bool

Microsoft SDKs - a huge list of SDKs.

## Detect 32bit or 64bit OS

32-bit or 64-bit. In an 64-bit OS all pointers are 8 bits wide.
//.net
if ( IntPtr.Size == 8 ) {
// 64 bit machine
}} else if ( IntPtr.Size == 4 ) {
// 32 bit machine
}}
//C++/C
if(sizeof(void*) == 4 )
// 32 bit
else(sizeof(void*) == 8 )
// 64 bit
`
IsWow64Process function (Windows)
Getting Processor architecture in x86 and x64 bit platform. - CodeProject - GetNativeSystemInfo

Programmatically (or Command Line) change the default sound playback device in Windows 7 : Dave Amenta

< Prev  Next >
Last Updated on Wednesday, 16 April 2014 10:23