Downloading and Installing the Source Code

How to get the sample programs

These files are taken from the VB6 update to the book. You can get the full context at Saying Goodbye to Visual Basic. If you can't wait for the update, you may download them here:

 

File Description
HardCore3.zip Source for sample program and components plus compare files, image files, and the Windows API Type Library-everything you need to build the VB components and samples.
HardCore35.zip Same as above, but for VB5.
WinTlb3.zip Source files for the Windows API Type Library-download only if you're interested in Interface Description Language (IDL).
CppForVB.zip Some C++ articles included on the book CD-download only if you're interested in C++ for Visual Basic.
WinTlbU.zip Unicode version of the Windows API Type Library-slightly more efficient for programs that will run only on Windows NT.
ComponentD.zip Debug versions of the built VB6 components.
ComponentR.zip Release versions of the built VB6 components.
Exes.zip Sample programs as EXE files.
ComponentD5.zip     Debug versions of the built VB5 components.
ComponentR5.zip Release versions of the built VB5 components.
Exes5.zip Sample programs as VB5 EXE files.

The Component and Exe files are for your convenience only. You could build the same files from the source. The only required file is Hardcore3.zip or Hardcore35.zip.

Recent printings of Hardcore Visual Basic (but not the first printing, unfortunately) have a directory called Goodies containing components and samples from readers of the first edition. These samples are not included, but you can get them at the Hardcore Hacker's Hall of Fame at www.pobox.com/HardcoreVB/hackhall.htm

Installation for VB6

Here is my recommended method of installation:

  1. Create a directory called Hardcore3 on your C drive. Actually, you can probably call it anything you want and put it on any drive you want, but this is the location I used. For owners of the second edition, I don't recommend installing over the original Hardcore2 directory, although I haven't tried it.
  2. Download HardCore3.zip and any of the optional zip files to the directory created in step 1.
  3. Unzip the files with the options that support creating files in their original directories. The options may vary depending on what zip tool you use. For example, if you're using a recent version of PkZip, the command line is pkzip -ext -dir Hardcore3.zip. If you don't unzip into the correct directories, nothing will work. Also, use a recent zip tool that understands long file names. If you unzip to short file names, nothing will work.
  4. Run the RegisterForVB batch file. This file registers the Windows API type library and copies the Cards32.dll and PSAPI.dll files used by some programs to the appropriate locations.

At this point you can use any of the VBG files for sample programs. You cannot use most of the sample VBP files because they reference components that haven't been registered. It's a good idea to get all the component files so that you can run any sample EXE or use any sample VBP. You can get the components in three ways:

  1. Download and unzip a component file (ComponentD.zip or ComponentR.zip). Again, make sure you unzip from the Hardcore3 root directory using options to create the correct directories. Run the ToDebug.bat or ToRelease.bat files to register all components. I recommend ToDebug initially. You can run ToRelease when preparing programs that use my components for distribution. These batch files (and UnregisterAll.bat) assume that RegSvr32.exe is in your path. If it isn't, you can either move it to a path directory or edit the batch files to point to the correct location. (By the way, I apologize for the original ToDebug and ToRelease, which assumed RegSvr32.exe was in a directory that existed only on my hard disk, and also ignored OCX files despite a message to the contrary.)
  2. Run the batch file BuildAll.bat. This will build either the Debug or Release components and executables. Pass d or r to the batch file to specify Debug or Release. If you didn't install Visual Basic in the default location, you'll have to specify the location in a VBEXE environment variable before you can build the files. The batch file identifies syntax problems and gives instructions if you get the syntax wrong. You can give a second argument to the batch file to build a group of files (components, controls, or clients) or to build an individual program.
  3. You can build each component project separately from its VBP file or from the VBG of a program that uses it. Most of the programs only require VBCore.dll and SubTimer.dll. Eventually you'll want to build VisualCore.dll, Notify.exe, and the controls-ColorPicker, DropStack, Editor, ListBoxPlus, and PictureGlass. The SieveCli program uses additional controls and components that have no practical use outside the program.

Installation for VB5

Some readers may not choose to update to VB6 since it is a minor release that offers as many problems as benefits for the hardcore programmer. All my programs are created with and tested under VB6, but it is possible to make everything work under VB5. There are several differences that must be fixed:

  1. VBP files created with VB6 have some statements that aren't recognized by VB5.
  2. CLS files have some properties that aren't recognized by VB5.
  3. I have used a few functions that take advantage of VB6 features.
  4. VBP and FRM files from VB6 use the new common control files that weren't available in VB5.

Most of these difficulties can be removed programmatically by running the VB6ToVB5.EXE program. That's how I created the files in HardCore35.zip. Originally I was going to provide only one version of the source files and tell VB5 users to run VB6ToVB5.EXE to convert them. Ultimately, this strategy fell apart. There were too many minor incompatibilities. Instead I used the conversion program to create the files myself, fixed various build problems, and put the files in separate zip files. The code in these two zip files is supposed to be identical (and I think it really is). The references, objects, and attributes in the VBP files, and the objects in the FRM files are the only differences.

Visual Basic should have a predefined compile-time constant for the version number like civilized development environments. It doesn't, so I added one. All my VBP files define iVBVer = x. You can see the entry in the Make tab of the Project Properties dialog for any of my projects. The x is 6 in the originals, but the VB6ToVB5 utility changes the version number to 5. My components have conditional statements that disable VB6-specific code. I also have a module, VB6Funcs.bas, containing implementation of VB6 functions for VB5.

Once you download the correct VB5 files, the installation procedure is the same as for VB6.

Directory organization

Keith Pleas, my would-be co-author on the VB6 update, was horrified at the original organization of the directories from the second edition. When I looked at the 386 files in the original Hardcore2 directory, I couldn't argue. Yes, that's a lot of unrelated files to cram in one directory. I admit it was rude. I guess I had so many other things to worry about that I didn't stop to think how intimidating this organization might look to users.

I've tried to improve the way I organized the directories for this release. The new organization may not be enough change to satisfy Keith, but it is an improvement. I want to find a compromise between books that have every program in a separate directory and those (like my second edition) that throw everything together in one big mess. Here's the new organization:

 

Hardcore3 Sample programs
\Components Source for components
\Controls Source for controls
\LocalModule General purpose private classes and standard modules
\Compare Compatibility compare files
\Release Release versions of components and controls
\Debug Debug versions of components and controls
\Exes Executable sample programs
\TlbSource Source for the Windows API Type Library
\CPP C++ articles
\Cpp4VB Four articles in HTML format on writing C++ DLLs
\Sieve First VBPJ article on writing ATL servers
\ShortCutSvr     Second VBPJ article on writing ATL servers

This new organization still leaves a lot of files in the root directory, but at least they're all for programs you can run.

Excuses

I don't suppose you want to hear my excuses if the installation procedure described above fails on your machine. But here they are anyway. I'm trying to be compatible with three operating systems-Windows 95, Windows 98, and Windows NT. Each of these systems may have different combinations of service packs or fixes contributed by different versions of Internet Explorer. In addition I want to be compatible with VB5 and VB6, knowing that VB5 has several service pack fixes and suspecting from the instability of VB6 that it will have service packs too. Furthermore, I'm trying to juggle builds from the IDE with VBGs or VBPs and builds from batch files with VBPs even though VB's build mechanism is unstable. Finally, since I decided not to write a Setup program in order to "save time," I have to do everything from the wretched DOS batch language.

Don't be too shocked if some of my projects don't build correctly on the first try. They worked on my machine, and they'll work on yours eventually if you tinker enough with the project files.