Solved

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

Posted on 2008-06-19
6
528 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
Comment Utility
MapFileAndCheckSum is what I always use:

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

0
 

Author Comment

by:BIAPRO
Comment Utility
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 500 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:BIAPRO
Comment Utility
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
Comment Utility
You've put it into a Module, yes?  Not a Form, and you're using VB6?
0
 

Author Comment

by:BIAPRO
Comment Utility
oops!,  no i did form will retry, thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The purpose of this article is to demonstrate how we can use conditional statements using Python.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now