Introduction to Go programmming language

by tsachi 11. January 2017 09:34


Using the Logitech cordlesss desktop bluetooth edition with Windows Server 2003

by tsachi 25. July 2009 13:11

I'll start with the conclusion : It's possible and feasible to make the Logitech cordless desktop ( bluetooth edition ) to work under windows server 2003. However, it was not a series of pressing next..

The Logitech cordless desktop comes with the following components:

1. Mouse

2. Keyboard

3. Charging station which function also as bluetooth radio

When the system is hooked up, by default, the charging station is working in compatibility mode. The compatibility mode is great - you have both keyboard and mouse working as HID devices under the device manager and you does need to install anything else. However, the bluetooth functionality does not work ( i.e. not bluetooth radio device ). If you want to work with the radio, you'll need to switch to bluetooth mode. Switching between the modes was not designed to be a user-action. It was designed to be implemented as part of the various drivers provided by Logitech and didn't work on windows server 2003.

In order to activate the radio, I did the following steps:

1. Install widcomm latest drivers ( ). You can find them on the internet. The version provided with the desktop ( 3.xx ) will work well only if you first switch to bluetooth mode and then load the drivers.

2. Switch your hub to bluetooth mode upon system startup.

In his blog Nynaeve provided a executable as well as source code for switching the bluetooth hub mode. The code/binary he provided ALMOST works. That is, it works as long as no other device/service is currently working with the hub. Since most of the time there are other services and joint devices  that are working with the hub, his code failed due to "missing privilege" error. Replacing the call to HidD_SetOutputReport with WriteFile seems to resolve the issue.

Next, I was looking for the VID (Vendor Identifier ) and PID ( Product Identifier ) in the device manager. The device to look up for is USB Composite Device under the Universal Serial Bus Controllers. Switch to the details tab and select the hardware Ids. The VID & PID can be retrieved from there. In my case these were VID = 046D ( logitech ) and PID = C703 ( product )

Now, you do have a backup mouse & keyboard pair right ? because for the next part you might need them.

Assuming you already installed the drivers, you need to with to bluetooth hub to radio mode.

You do this by running:

lhid2hci2.exe 046D C703

or replace it with your VID and PID respectively.

Just when you press the enter, your keyboard and mouse should stop functioning. Welcome to the bluetooth radio mode.

Now would be a good time to hook up your good old keyboard and mouse and go on.

Windows will automatically start installing all kind of drivers, and the bluetooth tray icon will turn green ( yheey! )

Create a simple batch file for running the lhud2hci2 on every startup so you will automatically have bluetooth support. (or you can do it as a service, using servany from ms)

Last using the backup keyboard and mouse, open the My Bluetooth Places and "find" your mouse and keyboard.

The lhud2hci2 with it's source code can be download lhid2hci2.rar (20.08 kb)


Compiling Code Composer Studio projects from command line

by tsachi 30. June 2009 19:10

Hardware companies makes great stuff. Especially when it comes to hardware. However, when it comes to areas which are not in their development focus, they tend not to do very well.

.. and Texas Instrument is no diffrent. Their H/W is designed and implmented quite well. However, when it comes to provide software support for it, they blow up. big time.

It took me quite a while to figure out how to implement the compilation automation. Officially, Code Composer does not provide any command line options. The only way to make it work thru command line is using the exposed COM interfaces.

The only way to compile their projects is via their user interface, or by using one of the two scripting techniques:

1. Perl

2. COM scripting language

The Perl implementation, as you could have guessed is a plain COM proxy. I will therefore skip their Perl solution and go right to the COM automation.

Below, you can find a script that takes a pjt ( code composer project file ) and compile it.

compilePJT.vbs (1.72 kb)

Please keep in mind that if you have more than a single version of code composer installed on the same machine, you need to re-register all the COM interfaces before compilation. ( I guess nobody at TI heard about COM Versioning.. )

Registering all the COM interfaces can be quite a long task since there are many COM files. Below you can find a link to a batch file that does all that work ( will work for code composer 2.2 )

ccs22_reg.cmd (22.85 kb)

 Last, the COM intefaces are basically mimics the user's actions. That means that if you forget to close the project in the script, an open code composer is still in memoery, with the project open.



Installing Visual Studio 2005 Service Pack 1 over Windows Server 2003

by tsachi 23. May 2009 15:23

It appears that microsoft has done it again..

 Error 1718.File '...' was rejected by digital signature policy

Another anomaly from the microsoft warehouse.

 Luckly for me, they actually confirmed this to be a bug and issued a pach.

the patch is available here :

and WindowsServer2003-KB925336-x86-ENU.exe (873.88 kb)


by tsachi 14. March 2009 16:12
public class MRUList<T> : List<T>


// Summary:

// Initializes a new instance of the System.Collections.Generic.List<T> class

// that is empty and has the default initial capacity.

public MRUList() : base() {}


// Summary:

// Initializes a new instance of the System.Collections.Generic.List<T> class

// that contains elements copied from the specified collection and has sufficient

// capacity to accommodate the number of elements copied.


// Parameters:

// collection:

// The collection whose elements are copied to the new list.


// Exceptions:

// System.ArgumentNullException:

// collection is null.

public MRUList(IEnumerable<T> collection) : base(collection) {}


// Summary:

// Initializes a new instance of the System.Collections.Generic.List<T> class

// that is empty and has the specified initial capacity.


// Parameters:

// capacity:

// The number of elements that the new list can initially store.


// Exceptions:

// System.ArgumentOutOfRangeException:

// capacity is less than 0.

public MRUList(int capacity) : base(capacity) {}

// Summary:

// Adds an object to the end of the System.Collections.Generic.List<T>.


// Parameters:

// item:

// The object to be added to the end of the System.Collections.Generic.List<T>.

// The value can be null for reference types.

public new void Add(T item)


if( Capacity == Count )




base.Add( item );







C# & .Net

C++ WinHttp wrapper class

by tsachi 14. March 2009 14:57

The source code for WinHttp wrapper covers the followings methods:

BOOL AddRequestHeaders( LPCWSTR pwszHeaders, DWORD dwHeadersLength, DWORD dwModifiers );

static BOOL CheckPlatform(void);

BOOL CloseSession();

BOOL CloseConnection();

BOOL CloseRequest();

BOOL Connect( LPCWSTR pswzServerName, INTERNET_PORT nServerPort );

BOOL CrackUrl( LPCWSTR pwszUrl, DWORD dwUrlLength, DWORD dwFlags, LPURL_COMPONENTS lpUrlComponents );

BOOL CreateUrl( LPURL_COMPONENTS lpUrlComponents, DWORD dwFlags, LPWSTR pwszUrl, LPDWORD lpdwUrlLength );

BOOL DetectAutoProxyConfigUrl( DWORD dwAutoDetectFlags, LPWSTR* ppwszAutoConfigUrl );

static BOOL GetDefaultProxyConfiguration( WINHTTP_PROXY_INFO* pProxyInfo );static BOOL GetIEProxyConfigForCurrentUser( WINHTTP_CURRENT_USER_IE_PROXY_CONFIG* pProxyConfig );


BOOL Open( LPCWSTR pwszUserAgent, DWORD dwAccessType, LPCWSTR pwszProxyName, LPCWSTR pwszProxyBypass, DWORD dwFlags );

BOOL OpenRequest( LPCWSTR pwszVerb, LPCWSTR pwszObjectName, LPCWSTR pwszVersion, LPCWSTR pwszReferrer, LPCWSTR* ppwszAcceptTypes, DWORD dwFlags );

BOOL QueryAuthSchemes( LPDWORD lpdwSupportedSchemes, LPDWORD lpdwFirstScheme, LPDWORD pdwAuthTarget );

BOOL QueryDataAvailable( LPDWORD lpdwNumberOfBytesAvailable );

BOOL QueryHeaders( DWORD dwInfoLevel, LPCWSTR pwszName, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex );

BOOL QuerySessionOption( DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength );

BOOL QueryRequestOption( DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength );

BOOL ReadData( LPVOID lpBuffer, DWORD dwNumberOfBytesToRead, LPDWORD lpdwNumberOfBytesRead );

BOOL ReceiveResponse( );

BOOL SendRequest( LPCWSTR pwszHeaders, DWORD dwHeadersLength, LPVOID lpOptional, DWORD dwOptionalLength, DWORD dwTotalLength, DWORD_PTR dwContext );

BOOL SetCredentials( DWORD AuthTargets, DWORD AuthScheme, LPCWSTR pwszUserName, LPCWSTR pwszPassword, LPVOID pAuthParams );

BOOL SetDefaultProxyConfiguration( WINHTTP_PROXY_INFO* pProxyInfo );

BOOL SetSessionOption( DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength );

BOOL SetRequestOption( DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength );

WINHTTP_STATUS_CALLBACK SetStatusCallback( WINHTTP_STATUS_CALLBACK lpfnInternetCallback, DWORD dwNotificationFlags);

BOOL SetTimeouts(
int dwResolveTimeout, int dwConnectTimeout, int dwSendTimeout, int dwReceiveTimeout );

static BOOL TimeFromSystemTime( SYSTEMTIME* pst, LPWSTR pwszTime );

static BOOL TimeToSystemTime( LPCWSTR pwszTime, SYSTEMTIME* pst );

BOOL WriteData( LPCVOID lpBuffer, DWORD dwNumberOfBytesToWrite, LPDWORD lpdwNumberOfBytesWritten );



WinHttp.cpp (6.92 kb)

WinHttp.h (2.83 kb)



Tags: , , , , ,



by tsachi 14. March 2009 14:26

HMODULE GetCurrentModule()



static int dummy;

VirtualQuery( &dummy, &mbi, sizeof(mbi) );

return reinterpret_cast<HMODULE>(mbi.AllocationBase);


Tags: , ,



About the author

9+ years experience in software, software engineering, software development, software architecture, software development methodology and practices, web, internet, intranet, distributed application, client/server, object-oriented analysis and design, requirements analysis and modeling, data modeling, and database design. Progressed through end-user application, servers and databases work to management positions. Held positions with management responsibility, including training and technological leading, for up to 5 employees. Engaged in computer applications development with focus over video streaming, web and security.