Solved

how to get the checksum of a file?

Posted on 2001-07-18
4
1,012 Views
Last Modified: 2012-08-13
The title says it all...  ;)

Regards,
Oli
0
Comment
Question by:Oli2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Accepted Solution

by:
Yunoshev earned 55 total points
ID: 6293787
MapFileAndCheckSum
The MapFileAndCheckSum function computes the checksum of the specified file.

DWORD MapFileAndCheckSum(
  PTSTR Filename,      
  PDWORD HeaderSum,  
  PDWORD CheckSum    
);
Parameters
Filename
[in] Pointer to a null-terminated string that specifies the file name of the file for which the checksum is to be computed.
HeaderSum
[out] Pointer to a variable that receives the original checksum from the image file, or zero if there is an error.
CheckSum
[out] Pointer to the variable that receives the computed checksum.
Return Values
If the function succeeds, the return value is CHECKSUM_SUCCESS.

If the function fails, the return value is one of the following.

Value Meaning
CHECKSUM_OPEN_FAILURE  Could not open the file.
CHECKSUM_MAP_FAILURE  Could not map the file.
CHECKSUM_MAPVIEW_FAILURE  Could not map a view of the file.
CHECKSUM_UNICODE_FAILURE  Could not convert the file name to Unicode.


Remarks
The MapFileAndCheckSum function computes a new checksum for the file and returns it in the CheckSum parameter. This function is used by any application that creates or modifies an executable image. Checksums are required for kernel-mode drivers and some system DLLs. The linker computes the original checksum at link time, if you use the appropriate linker switch. For more details, see your linker documentation.

It is recommended that all images have valid checksums. It is the caller's responsibility to place the newly computed checksum into the mapped image and update the on-disk image of the file.

Requirements
  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Imagehlp.h.
  Library: Use Imagehlp.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

0
 
LVL 1

Author Comment

by:Oli2
ID: 6293823
oh well, looking up the WinApi help file could've saved me this 55 points I guess...  ;)

Thanx,
Regards,
Oli
0
 
LVL 1

Author Comment

by:Oli2
ID: 6293891
How to implement this in Delphi though ????????

Delphi don't know MapFileAndCheckSum(),
it doesn't know MapFileAndCheckSumA() and doesn't know
MapFileAndCheckSumW().

regards,
Oli
0
 
LVL 1

Author Comment

by:Oli2
ID: 6293904
never mind, worked it out.

Oli
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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