Feeds:
Posts
Comments

Archive for the ‘C++’ Category

My problem: A program was using 127.0.0.2 (an alias for 127.0.0.1) to make a local connection on a specific port. However, one Windows 2003 server box was configured so that this port was being listened to on a specific network adapter (and hence a specific IP address). Hence, my local connection failed even though the [...]

Read Full Post »

I’ve always wondered (and again two days ago) what “irreversible loss of information” is being referd to when you reset a local user password from the “Computer Management” console.  Independantly, I’ve been tracking down a bug reported by one PMG Connect user in which the connection routine fails.
These things are linked.  The bug was a call [...]

Read Full Post »

WinHttpGetProxyForUrl also blocks.  This is despite the documentation saying that it won’t if you close the handle during it’s operation.  (Let’s face it, Microsoft programmers often have a very loose sense of the meaning of block, what’s a minute or two.)  Anyway, this called for a generic class for blocking things (see previous post re [...]

Read Full Post »

Managed, Unmanaged and COM

I’m wrapping a legacy lib for use in a .NET envirment. 
Usefull: An Overview of Managed/Unmanaged Code Interoperability
Firstly, I tried to wrap the lib api with COM and use that from my C# app.  With speed and efficiecency a priority, this was unacceptable.  It involves callbacks (legacy lib) or events (COM) – the big slowdown happened in [...]

Read Full Post »

Custom Draw Toolbar

After WPF, spending time with NM_CUSTOMDRAW seemed like running somewhere, when one could catch a bus.  Someday, we may even do it’s like for pleasure.
My problem: I couldn’t get the separators to draw on my owner draw toolbar.  Apparently, the NM_CUSTOMDRAW doesn’t send a CDDS_ITEMPOSTPAINT for separators.  So, the way to do it is draw your separator over [...]

Read Full Post »

Lazy Value

I wanted to replace a const int with a lazily evalueated int.  It had to be lazy evaluated as all that was needed to calculate it was not available when the class is instanciated but was available before the int was needed. I didn’t want to change the code that uses the int.  So, I made this class:

template <class T>
class CLazyValue
{
public:
   CLazyValue() : [...]

Read Full Post »

Does the file exists

After about 16 years of writing C++ on Windows I’m sure there’s been many an occasion with the need to test if a file exists.  Today, I discovered a new way to check!

bool FileExists(const extra::tstring &file)
{
   OFSTRUCT of = {sizeof(of)};
   return (OpenFile(CT2CA(file.c_str()),&of,OF_EXIST)!=HFILE_ERROR);
}

Where an extra::tstring is declared such (part of my library of code):

typedef std::basic_string<TCHAR>tstring;

Apparently it [...]

Read Full Post »

This is assuming your COM object is a dual interface object (implements IDispatch).
1) Create a text file with a .js extension (eg: test.js)
2) Load the file into Visual Studio.
3) Put the following line at the top:
var arbiObj = new ActiveXObject(“ArbiCOM.ArbiClassProx”);
where “ArbiCOM.ArbiClassProx” is the prog id of your COM object.
4) VS will have intelisense (bellow type [...]

Read Full Post »