Category Archives: Uncategorized

VB6 and Typelibs

4
Filed under Uncategorized

Ages ago, I happened onto Bruce McKinney’s HardCore VB and the Win.TLB file that he created and I was hooked.

Ever since, I’ve been a big fan of using typelibs with VB6. They’re relatively compact, support help, work nicely with Intellisense, and, most importantly, any elements of a typelib that your project doesn’t use, don’t get compiled into you project, unlike standard VB DECLARE statements.

Furthermore, typelibs provide just about the ONLY way to access certain COM interfaces that are normally declared with attributes that make them unusable by VB.

For examples of that, check out Edanmo’s page, or the VBAccelerator stuff.

I’ve been using Matt Curland’s Excellent PowerVB Typelib editor to edit, extend, and generally hack and bash the original win.tlb (I generally don’t use unicode much explicitly, so I haven’t kept the WINU.TLB unicode variant up to date, unfortunately). Note, though that you have to buy the book to get the editor. If you do this much, the editor alone is worth it, but the book is truly the best books on low level VB6 out there.

Doing things the Right Way

However, I really wanted to get this thing back into shape, and I felt like the best way to do that was to get it BACK into IDL format, and then use the MIDL compiler on it.

You’d think that doing so would be, basically:

  1. Load the TLB into OLEVIEW
  2. Export the whole thing as an IDL file.
  3. Edit the IDL with a text editor
  4. Run MIDL on it to recompile the WIN.TLB and presto! Nice new, clean tlb file.

Sigh. Is anything ever that simple?

Problems, Problems

First, OLEVIEW exports things in completely the wrong order (I’m not exactly sure what it uses to order things other than just the defined order in the TLB). As a result, I got tons of “symbol not defined” errors when I compiled, because a call referenced a structure that was defined later in the IDL, and didn’t have forward declaration.

Shuffling LOTS of typedefs around, I resolved all that, only to end up with tons of MIDL2022 “illegal or missing value for entry attribute”, as well as MIDL2270 “duplicate UUID” errors.

The duplicate UUID errors I fully understand, even though I really don’t like it. Basically, the TLB “redefines” a number of internal COM interfaces to make them usable by VB, for instance IEnumString.

However, MIDL doesn’t allow you to redefine an interface that already exists, and that particular interface does already exist.

In that case, commonly, you just rename your new definition to, say, IVBEnumString.

And with mktyplib and Matt’s TLB editor, that’s no problem. But MIDL see’s the old IEnumString (defined in the automatically INCLUDEd OBJIDL.IDL) and the new IVBEnumString, notices that they have the same UUID (which they must) and throws that MIDL2270 Duplicate UUID error.

Bruce resolved this by actually copying the OAIDL.IDL, OBJIDL.IDL, UNKNWN.IDL and WTYPES.IDL from the Visual Studio 6 Include dir right into his TLB project, and modified them as necessary. It works because of the MIDL search rules, but I REALLY didn’t want to continue mucking with the MS IDL files. I’d much rather just redefine those that I need to redefine and be done with it. Just seems like a safer alternative.

Ok, fine, so I go back to mktyplib and move on.

Not so fast, young Skywalker!

mktyplib is an older tool (read, unsupported, not maintained, and generally considered just that much bit junk now). And sure enough, a very common element in my type lib, it doesn’t support, namely non-variant optional parameters.

I have a line of ODL (mktyplib’s prefered input file type) like:

      HRESULT _stdcall Commit([in, optional, defaultvalue(0)] STGC grfCommitFlags);

And it has no idea how to handle that OPTIONAL and I have too many of these to bother counting them all (ok, not really, there’s 64).

I really don’t want to have to make all those method parms suddenly “required” when they’re not.

The Cycle of Irritation

So, here I am, hours later, and back where I started.

I’m going to continue using the PowerVB editor to update the WIN.TLB file.

And just to recap, my version started from Bruce McKinney’s ANSI version, generally targeted at VB5, then pulls in LOTS of additional COM interfaces, ala Edanmo, VBAccelerator, and others, corrects some issues with certain calls that VB5 had no issues with but VB6 didn’t like, throws in lots of new ENUMS for parameters of functions instead of just blind LONGs where you get no Intellisense, and rounds things out with a little bit more help text for some methods (though that’s still pretty spotty).

One nasty habit of TypeLibs

One thing to be very careful of if you do start working with typelibs, is to make sure that any API function you decide to pull in and actually use will exist on the target machine.

These days, that’s not particularly hard. Win2k through Vista have changed very little as far as typical low level API’s are concerned.

At one point, my apps were running on everything from Win95 through XP, and there were definitely issues with commonly used functions existing under Win2k or XP that had no equivalent under 95 or 98. In those few cases, I just resorted to a standard VB declare and then error trapped the call. If the function wasn’t available, you’d get an error, trap it and deal with it.

However, if that same function was defined in a typelib, the app loaded will validate all implicitly linked libs and try to resolve them all at load time. If it failed for ANY function, the app won’t load at all, and all this happens before any of you VB code has a chance to do anything about it.

AIM Wimzi

0
Filed under Uncategorized

I recently blogged about showing your ICQ status on a webpage and I get this in the mail….

AIM now has a service called WIMZI that allows you to embed a little script on a page and lets visitors to a site chat you up without getting your AIM ID, etc.

image

Very interesting. Even better than the status indicator because a visitor can start a chat right there on the site. A bit like those “Chat with a support rep” services, but it’s effectively free.

I wonder if that will end up having an impact of any sort on the paid offerings. I’m guessing they support a bit more accountability, plus some amount reporting (number of chat requests answered per rep, that sort of thing).

I’ll have to try it out here soon.

Visual Thesaurus

2
Filed under Uncategorized

Years ago, I used SideKick as my PIM, then I ran into Tornado Notes for DOS, which became InfoSelect for DOS, which got ported to Windows 3.1, and which is, in it’s latest incarnation, still my PIM of choice.

But during my search, I kept coming back to a very interesting little app called TheBrain.

image

A static picture doesn’t do it justice, you need to navigate around in it to get the full effect. It’s gaming meets info management if ever I’ve seen it.

I never could see the benefit of that kind of arrangement for managing your personal information because, for my personal info, I already know how things are connected, I just can’t remember the details.

But for navigating information that you don’t know much if anything about in the first place… Now that’s where this kind of thing can shine.

And back in the present, I just stumbled onto The Visual Thesaurus that does just that. It’s a pretty nifty way to explorer around seeing relationships to words visually. I could definitely see children learning lots of new words by navigating through similar words they already know. Plus, its got that “video game” flare that screams Play With Me!

Or how about a visual code navigator, for developers new to a large project. Browsing through a project using that metaphor could be very illuminating, very quickly.

I’m not sure that Visual Thesaurus will actually make it or not. I don’t see many people paying even their low $2.95 “subscription” for it. But the idea, and more importantly, where it’s been executed, seems like a good one to me.

Can I get that in an OCX?

New for the Christmas List

4
Filed under Uncategorized

I just ran into an ad for Dell stuff on the Wired website.

Normally, I don’t click ads, but I like Dell widescreen lcd monitors, so I had to check it out.

Dell is now offering a 30″ Widescreen monitor! (I just wish one of their pictures put a soda can in for scale reference)

image

Its the 3007 WFP-HC, and, if it’s even remotely as good as the 2405FPW or the 2007FPW (I have one of each of these), it’s gonna be tough to resist clicking that “order now” button.

Check this blurb out from the site:

Note: For the best viewing experience, your PC must have a dual-link DVI-D graphics card that supports 2560 x 1600 resolution.

2560×1600 resolution. In the immortal words of Keanu Reeves, Whoa.

That’s a pile of pixels to be pushing around.

One of the guys I worked with asked me how I could program in white text on a black background. Put this baby on your desk, load up VS2005 and maximize it, then try staring at ~400 square inches of FFFFFF about 24″ from your face for 8+ hours a day. The 24″ Dell I have can light up my office all by itself with a full white screen. 

You could use this thing to signal aircraft.

The Ultimate Developer Rig

0
Filed under Uncategorized

Scott Hanselman recently did a very nice series of posts about building his “Ultimate Developer Rig“, a quad core, dual PCIE video card monster machine, that certainly has some impressive specs to it.

That Scythe Cooler is particularly impressive:

image

Too bad he didn’t totally geek out and put a plex window and some light tape in there… Too much?

Now, there are some that would say this is the “Ultimate Developer Rig”:

image

(For the full specs, check it out here.)

But I gotta say, Scott’s setup is pretty hardcore. In fact, it’s almost eery the similarities between Scott’s rig and the one I put together a little less than a year ago. I went with a dual core E6600 because, well, if the quad cores were even out at that time, they had to be too rich for my blood. I tried, hard, to justify the 1000$ for a E6700 Core 2 Duo Extreme at that point, but just couldn’t do it.

Still, my rig gets right up there, scoring a 5.5 on the “Windows Experience” scale in Vista. If I was so bold as to delve into overclocking, I might even improve on that some. Maybe eventually.

Then, I stumbled upon Kevin Hammond’s commentary on Scott’s rig, and I have to say, I’m right there with Kevin.

I diverged from Scott’s rig in much the same ways Kevin recommends, with a few minor deviations:

  • Vista 64 just isn’t ready from primetime, due to driver and utility support
  • RAID 10 is hard to beat for resisting downtime
  • I went originally with a Gigabyte GA 965P DS3 board, but then switched to an Intel D975XBX2 when I discovered the Gigabyte didn’t do 4 drive RAIDs
  • I used a Zalman cooler instead of the Scythe. I guess I’m partial to copper
  • Scott damped the inside with foam. With that Antec case, I haven’t noticed the need to. It’s virtually silent once the fans initially power up.

About the RAID, George Ou wrote a pretty good article on half-stroking or quarter stroking a harddrive to improve its performance. No idea whether it has similar effects on a RAID. In other benchmark tests, George pretty much slays RAID 10, which I’m a fan of. I’ve lost a drive out of a RAID 10 setup, replaced it and was on my way with no downtime. But when I lost a drive out of a RAID 0, I was down for almost 3 weeks trying to get everything back and operational. And drive images are only good if almost everything else about the machine stays the same, which, in my case, didn’t.

None the less, if you’re looking to put together a wickedly fast machine for under 2 grand, and you want it to be so quiet, you NEED lights on the outside to tell it’s on, I highly recommend reading through Scott’s parts list.

FrogBot 2007

1
Filed under Uncategorized

I’m a diehard technophile, but this makes even me a little unsettled.

image

It’s a whole computer, INSIDE a frog, a real, albeit dead, frog, suspended in a tank. The computer is a webserver. You can browse the site and click buttons to “activate” its left and right legs.

For the full project info, check Frog Implanted with Webserver.

Hmmm, I can’t even think of any quip to go with that.

Registering VB6 Office COM Add-ins as Per-Machine

8
Filed under Uncategorized

Office COM addins can be registered in one of two ways:

  • Per user
  • Per machine

Per User addins will be loaded for the user that the addin was registered to. This is the common situation with addins created in VB6. Typically, this means that whatever user was logged in when your addin was installed, is the ONLY user that it will be registered for.

It’s simple enough to run regsvr32 again on your addin dll while logged in as a different user to register it for the new user but this can really be a pain in a big IT shop.

Per user addins are registered under the HK_Current_Key hive in the registry. For instance, Word add ins can be found here:

HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins

Other Office apps, namely Excel, PowerPoint and Outlook, store their addin entries in similar locations in the registry.

Per Machine addins, on the other hand, are registered in the same key, but in the HKEY_LOCAL_MACHINE hive, so, for instance, here:

HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Word\Addins

Per Machine addins have the benefit of being registered once but loaded no matter what user is logged in. Definitely a bonus if you commonly have multiple users on a machine.

The problem is, VB6 automatically sets up the addin designer object such that it registers add ins as Per User addins.

This is pretty easy to fix, however.

Here’s a snippet from the very top of a DSR file for a Word addin (Open the file using notepad or some other text editor, NOT using VB6):

VERSION 5.00
Begin {AC0714F6-3D04-11D1-AE7D-00A0C90F26F4} WordAddIn
   ClientHeight    =   6465
   ClientLeft      =   4815
   ClientTop       =   1215
   ClientWidth     =   10020
   _ExtentX        =   17674
   _ExtentY        =   11404
   _Version        =   393216
   Description     =   “My Word COM Add In”
   DisplayName     =   “MyAddIn”
   AppName         =   “Microsoft Word”
   AppVer          =   “Microsoft Word 9.0”
   LoadName        =   “Startup”
   LoadBehavior    =   3
   RegLocation     =   “HKEY_CURRENT_USER\Software\Microsoft\Office\Word”
End

Note the RegLocation element.

Simply change that to HKEY_LOCAL_MACHINE (but leave the rest of the key alone), recompile and Presto! Your add in is now a Per Machine addin.

There’s only one snag with this, though. Every time you make a change to your DSR file, VB will automatically switch that entry back to HKEY_CURRENT_USER. Oh, the helpfulness.

But, never fear, there’s a solution here as well. Just never change the DSR<g>.

Seriously though. Simply create a separate class, expose some public methods on it that mirror the event signatures of those in the DSR file itself, and then pass the events on through the DSR to your new class.

That way, your DSR file never has to change, but you can change your class all you want and never have to worry about VB switching up the RegLocation on you.

For instance, in your DSR file, there will generally be an AddinInstance_OnConnection event that is fired when the host application is loading up your addin. Define it something like the following:

Dim rAddinClass as AddInClass
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
      ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
      ByVal AddInInst As Object, custom() As Variant)

   'Create and Initialize a base class
   Set rAddinClass = New AddInClass
   rAddinClass.OnConnection Application, ConnectMode, AddInInst
End Sub

Then, in your AddInClass.cls file, define a function like

Public Sub OnConnection(ByVal Application As Object, _
      ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
      ByVal AddInInst As Object, custom() As Variant)

   'Do Whatever you need to do during the OnConnection event here
End Sub

When the host app (could be Outlook, Word, Excel, or PowerPoint, they all work the same), loads your addin, it will fire the OnConnection event. The sub in your DSR file will get called, which will then call the corresponding sub in your Addin Class and you can do whatever coding you need to do, never having to change the DSR file again.

Or you can try to write addins in VB.NET using VSTO, suck up about 10x the diskspace and memory, and have to deal with things like COM shims, and other splinters of joy.

Star Wars at the Museum

0
Filed under Uncategorized

image

Checked out a very cool exhibit yesterday.

The Ft Worth Museum of Science and History is presenting “Star Wars: Where Science Meets Imagination” till Sept 3.

It’s got plenty of interactive stuff for the kids (that most likely won’t have any idea what Mos Isley, a Jawa Transporter, or a Rebel Blockade Runner is).

Plus, it’s got stuff from Mos Isley, the actual Jawa Transporter (model), and the original Rebel Blockade Runner (model). Can’t get much better? Oh, but it can.

How about the original, 70lb model of the Millennium Falcon, the original Landspeeder (that looks ultra-cheesy up close!), and the first Vader costume, plus quite a bit more.

I’m sure it’s touring, but I couldn’t find out any info on other museums it’ll travel to next, so be on the lookout in your area. 

Good stuff.

image

Showing your ICQ status on a web page

0
Filed under Uncategorized

First, the disclaimer, I’m doing all this in ASP.NET 2.0 with VS 2005. If you’re using plain old ASP, or VS 2003, it may or may not work.

To begin, you’ll need to add an IMG tag somewhere on your page (or, in the case of dasBlog, somewhere in the homeTemplate.blogtemplate file that’s part of the theme you wish to use. Note: If you allow users to change the theme in dasBlog, then you’ll need to add this IMG tag to all themes you’d like it to be part of. For this blog, I disabled the switching of themes, so I only had to add this tag to one file.

<img src="./themes/[your theme name]/IMStatusImageProxy.aspx?type=ICQ"
title="Tooltip your want to display" >

Where [your theme name] is just that. This just allows you to put the  IMStatusImageProxy.aspx file in your theme path. If you prefer, you could copy it to the dasBlog root path and just reference it there.

This tag causes the browser to go and load the IMStatusImageProxy.aspx page for the image to use when it needs to obtain the image for the IMG tag. Now, that ASPX page isn’t actually  an image at all, but the browser doesn’t care at this point.

Next, create the IMStatusImageProxy.ASPX page. You’ll need to put it in your theme’s folder (or in the dasBlog root as I mentioned above).

<%@ Page Language="VB" %>
<script runat="server">
' ------------------------------------------------------------------------------------------
' IMStatusImageProxy.asp
'
' Used to retrieve the content of the status image from 
' websites that serve them up.
' I don't believe there's a way to avoid the proxy page
' when pulling the images. At least not and remain easily compatible with
' dasBlog.
' The original idea is from Dino Esposito.
' ------------------------------------------------------------------------------------------
   Private Function pGetWebPageImage(ByVal URL As String) As Byte()
      '---- Create the HttpWebRequest object
      Dim req As System.Net.HttpWebRequest = System.Net.WebRequest.Create(URL)
      Dim Results As Byte()

      Try
         '---- Get the data as an HttpWebResponse object
         Dim resp As System.Net.HttpWebResponse = req.GetResponse()

         '---- Convert the data into a string (assumes that you are requesting text)
         Dim br As New System.IO.BinaryReader(resp.GetResponseStream())
         Results = br.ReadBytes(50000)
         br.Close()

      Catch ex As System.Net.WebException
         'Something went awry in the HTTP request!
         ReDim Results(0)       End Try       Return Results    End Function    Public Sub Page_Load()         '---- Retrieve the TYPE of IM system whose status         '     is being requested         Dim IMType As String = Ucase(Request.QueryString("type"))
        Dim ImgType as String = "image/gif"
        Dim r() as Byte         '---- set up the response object
        Response.Expires = 0         Response.Buffer = True         Response.Clear()         '---- Filter for the good arg values         '     we don't want to allow just any old parm value in         Select Case IMType             Case "ICQ"                '---- handle ICQ status                '     ICQ makes this relatively easy because they have a service to                '     retrieve that info                '     Retrieves a GIF type image                r = pGetWebPageImage("http://status.icq.com/online.gif?icq=[YOURICQNUM]&img=16")                            'Case "AIM"                '---- handle AIM status here                            'Case "HOTMAIL"                '---- handle AIM status here                            Case Else                '---- not a valid IM type so bail out                Response.End()                Exit sub         End Select         '---- set the image info saved from the main page         '     into the response object         Response.ContentType = ImgType         Response.BinaryWrite(r)         '---- since this is a proxy, end the response now         Response.End()     End Sub </script>

You’ll obviously want to replace [YOURICQNUM] with you’re own ICQ number. However, since your ICQ number is in the code portion of the ASPX page, it won’t be visible in any way to the web browser, and hence, the public.

Also, the &img=16 is a parameter that indicates to the ICQ webservice which imageset you’d like to use. You might want to experiment with different numbers, from 1 on up. 16 looked pretty good to me.

Essentially, the idea of this proxy page is to:

  1. Retrieve the IM type you’re wanting status for. In this case, I’m only supporting ICQ right now.
  2. Clear out the response buffer and make sure it can’t get cached (because the status could change from one page refresh to the next).
  3. Retrieve the web page image via the web service in whatever manner is appropriate. The image comes back in a BYTE() array.
  4. Set the ContentType of the response appropriately (this tells the browser that what’s coming back is a binary GIF image)
  5. and finally write the contents of the BYTE array that was retrieved earlier.

I thought this approach was quite nice for several reasons

  • It doesn’t require creating a MACRO for dasBlog. That’s not hard to do, but if you don’t have to…
  • It doesn’t require inline code in the dasBlog theme template. From what I can tell, dasBlog doesn’t support inline code in templates anyway. If I’m wrong about that, please let me know!
  • What is required in the theme template is spectacularly easy to deal with (one IMG tag).
  • It shows your status without revealing your ICQ number, which is appealing for a variety of reasons.
  • All the required code is completely encapsulated in the IMStatusImageProxy.ASPX page.
  • Finally, you should be able to stick this page into any ASP.NET 2.0 based site and get the functionality. It doesn’t require dasBlog at all or any other 3’rd party stuff.

Let me know what you think!

ICQ Status Indicator is Online

0
Filed under Uncategorized

I’ve been playing with this idea for a while. Basically I’ve been looking for a nice simple way to add an IM status indicator to this web page. That way, visitors would be able to see if I’m actually around to chat.

But I had a couple caveats.

  1. I didn’t want to make my ICQ number publicly available on my site (IM spam is just too god-awful to think about)
  2. It had to work with ASP.NET 2.0 and dasBlog.

I’m happy to say I think I came up with something that might actually work, though I’m still testing it.

I’d love to show status for all the major IM systems (I’m on Google Talk, Yahoo, MSN, ICQ, and AIM), but ICQ seems to be the easiest to get up and running, so I’ll stick it with for the time being.

If you’d like to get my ICQ number, just email me. There’s a little email button right above the ICQ status indicator (it’s the envelope icon in the upper right). That button now actually works, too, which is new. It’ll display a form for sending me an email (that way, my email address isn’t exposed on the page, either).

And, once I clean it up a bit, I’ll blog the actual ASP code that makes the ICQ status indicator possible.