Page 1
Page 2
Because eMbedded Visual Basic does not
allow you to create an .exe file, there are a couple of
basic things that suddenly become difficult. Making a custom
icon for your program is one of them. By now you are probably
aware of a "workaround" where you create a launcher
application in C++, and that launcher application provides
a shortcut (and therefore a custom icon) to your application.
One thing that would seem impossible at first glance is
creating a file association with your eVB application. Sure,
you can create the registry entries to associate a file
type with your eVB application, but what happens when you
tap on that file in File Explorer? The command line parameters
go to pvbload.exe and not to your application, and your
application has no way of knowing which file was tapped
on.
With this article, we will expand the
C++ launcher application to do one more very important thing
- intercept the command line parameters and pass those to
our eVB application. First, I'll give you the bad news about
this technique. It does involve using Visual C++, API calls,
reading and writing to the registry, and more workarounds
than the TV series MacGuyver would be comfortable with!
But, the good news is I will spell all this out for you,
and you will find that with just a few changes, the sample
code can be adapted to your particular application.
Let's start with the C++ launcher application.
Explaining the C++ code used here is beyond the scope of
this article. To the new user, Visual C++ can be about as
intuitive as giving a fish a bicycle. But fear not, all
you need to do here is change the sample code in two places.
First, you will change the place where the command line
is written to the registry. You'll change this so that the
registry key used ends up in a path that is meaningful to
your application. This is found in the MyEVBLauncher.cpp
file.
To open the workspace in eMbedded Visual
C++, choose File, Open Workspace, and then
browse to the MyEVBLauncher.vcw file. Then click
on the file view tab and find the MyEVBLauncher.cpp
file under Source Files.
Our current code looks like this:
RegCreateKeyEx(HKEY_CURRENT_USER,TEXT("Software\\MyCompany\\MyAppName"),
etc...
This line tells the C++ launcher where
to write the command line parameter to the registry. Notice
the double "\\"'s are necessary in C++ for the
path name. You can change this path to a path that you think
would be an appropriate place to store information about
your application.
Next you will change the line of code
containing "MyEVBApp.vb" to the name of
your vb file. This tells the C++ launcher file which .vb
file to launch. This will launch our .vb file as
long as it resides in the same folder as our .exe launcher,
so this will even work if installed to a storage card!
The places where changes are necessary
are highlighted with comments in the C++ source code, so
they should be easy to find. See, that wasn't so painful
now, was it? This might also be a good time to change the
program icon to your custom icon. To do this in eMbedded
Visual C++, click on the "resources" tab (usually
near the bottom left of the screen) and then click on the
plus sign beside the "Icon" folder. Then click
twice on the now revealed IDI_ICON1 file. This will open
the icon and the resource editor. There will be a "Standard"
32x32 size icon and also a smaller 16x16 icon. You will
want to customize both for your particular application.
Now we will compile the .exe file for
our new launcher. From the eMbedded Visual C++ Build
menu, choose Batch Build, and select the ARM, MIPS,
and SH3 release versions. Click the Build button
and .exe files for all three processor types will be placed
in folders called ARMRel, MIPSRel, and SH3Rel. We'll leave
these files here for now, and come back to them later. You
can now breathe a sign of relief; we are done working with
Visual C++!
The next step will be making our eVB
application read the command line parameter that our C++
launcher will be writing to the registry. In the sample
project files there is a MyEVBApp project. It includes
a module that handles registry reading and writing. You
can get more information on this code from this
deVBuzz article, but for our purposes here, you can
plug it into a module and it will provide us with the QueryValue
function that we will use to read our registry entry. In
our code we have defined our Section as HKEY_CURRENT_USER,
our Key as "Software\MyCompany\MyAppName",
and our Subkey as "FileName". This matches
up with the key that was written in our C++ launcher. When
our eVB program loads, it will read the registry key written
by the C++ launcher and display it in a message box.
Now, the final step will be to create
the file association, so that the file type our application
uses can be opened directly from File Explorer. We're going
to associate a .mrb file with our eVB program. To
do this, we need to roll up our sleeves and go after the
.inf file used in our application's install process.
When we use the Application Install
Wizard in eVB (under Tools - Remote Tools
- Application Install Wizard), it creates for us
several files, including an .inf file used for compiling
our .cab files for installation. In this case, since
our project is MyEVBApp, we will find a file called
MyEVBApp.inf in the folder we chose during the Application
Install Wizard process. Let's open this file in notepad
and have a look.
This is where things get messy. Manually
modifying the .inf files is required, and that can be about
as much fun as a urinary tract infection. But again, we'll
take it step by step, and you will be through it in no time.
There are several things we will need to change here. First,
under the [Shortcuts] section, let's change the "MyEVBApp.vb"
to the name of our .exe launcher file, which in our example
is "MyEVBLauncher.exe". This change tells the
installation process to point the Programs menu shortcut
to our new C++ launcher file. Next, let's make sure our
.exe file gets included in the installation by adding the
line MyEVBLauncher.exe=3 under
the [SourceDisksFiles] heading. Then, under [Files.App],
add MyEVBLauncher.exe (without
the =3 this time).
Finally, we want to tell our installer
to make the necessary registry entries to make .mrb files
associated with our application. So, under the [DefaultInstall]
heading, let's add a line that looks like this:
AddReg=RegEntrys
Next Page