?
Solved

ADDING A CHECKSUM TO A VB6 ACTIVEX MODULE AND CHECK AT PROGRAM START IF STILL VALID CHECKSUM

Posted on 2008-06-19
6
Medium Priority
?
607 Views
Last Modified: 2008-06-22
I use a activex module to control the comport connected to a scale and a scanner.
By Dutch law it must be impossible for a user to change the activex module in any way, so that after the tested it, they can control later on
if the software version is different then the one they tested.
How to add a checksum to the Activex and then when starting the program wich uses it,  check for valid checksum, so I can abort if changed
0
Comment
Question by:BIAPRO
  • 3
  • 3
6 Comments
 
LVL 10

Expert Comment

by:peetm
ID: 21823321
MapFileAndCheckSum is what I always use:

http://msdn.microsoft.com/en-us/library/ms680355(VS.85).aspx

0
 

Author Comment

by:BIAPRO
ID: 21823386
I took a look at this link, I believe it will do what I need, but far above my level of understandimg without some source code sample how to use this while/after compiling the ocx file, and when starting my vb program how to check if still ok.
But thanks for time anyway
0
 
LVL 10

Accepted Solution

by:
peetm earned 1500 total points
ID: 21823499
Here's a cut 'n paste from one of my projects.

Public Declare Function MapFileAndCheckSum Lib "imagehlp.dll" Alias "MapFileAndCheckSumA" (ByVal fileName As String, ByRef HeaderSum As Long, ByRef CheckSum As Long) As Long


' ================================================
' Uses imghelp.dll to calculate a file's checksum.
'
' This routine could be used to verify that files have been copied/moved ok.
'
Public Function CheckSumOfFile(ByRef fileName As String) As Long

    Dim CalcedCheckSum As Long
    Dim HeaderCheckSum As Long

    ' MapFileAndCheckSum returns this f it worked.  Can't see much point in testing this here though.
    '
    Const CHECKSUM_SUCCESS As Long = 0

    ' HeaderCheckSum will only be non-zero if the file being checksumed is a binary [exe, dll, ocx, ...]
    ' that contains checksum info, e.g., the stuff that dumpbin.exe would list by 'checksum' when used
    ' like this for example ... dumpbin /headers c:\windows\system32\systray.exe
   
    Call MapFileAndCheckSum(fileName, HeaderCheckSum, CalcedCheckSum)

    CheckSumOfFile = CalcedCheckSum
   
End Function
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:BIAPRO
ID: 21823602
just plain copy this to start with in a new project, i got error at start run

Constants,fixed-length strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules
0
 
LVL 10

Expert Comment

by:peetm
ID: 21824186
You've put it into a Module, yes?  Not a Form, and you're using VB6?
0
 

Author Comment

by:BIAPRO
ID: 21824234
oops!,  no i did form will retry, thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question