Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > API > I need some help!


Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2005, 10:55 AM
picnaut picnaut is offline
Newcomer
 
Join Date: Nov 2005
Posts: 3
Question I need some help!


Hello VB Masters!

I need some help.
I've been doing research on the net and I am still no closer to success with my project.
Hopefully you can provide the answers to my questions.

I need a few things and I'd appreciate some brief usage examples (especially with registry related stuff).
I'd like to use Windows API calls where possible, and I'd prefer to have it backwards compatible to at least Windows 98.
In other words, if XP has a version of a particular API routine that is more efficient than the Windows 98 equivalent, I'd still like to use the Windows 98 routine. Actually, I could probably use both and have my program decide which one to use.

All I have is VB6, so NO VB.net examples please.


1) READING & WRITING TO THE REGISTRY

I need to be able to READ from and WRITE to values in the Windows registry.
I know how to find the particular value using Regedit, but I've tried using VB with Windows API's and I can't seem to get it to work.
Currently, I just want to "read" a string value and "read and write" a boolean value (0 or 1).
For instance, I need to read a string value called "LastFile" that's located in the following registry path: HKEY_CURRENT_USER\Software\NameOfSoftwareManufacturer\SoftwareName\Edi tor
I also need to read and write to a boolean value called "FullTitleFilename" that's located in the following registry path: HKEY_CURRENT_USER\Software\NameOfSoftwareManufacturer\SoftwareName\Opt ions



2) COMPARING TWO FILES

I need to be able to compare two files to see if they're different. I don't need to know what makes them different, but just that they ARE different. Does Windows embed some kind of checksum in files (i.e. a simple text file)? If so, reading that would probably be the least resource intensive.



3) DETECTING CONSOLE EXECUTABLES

I need to detect if an "old school" console (DOS-like) executable is running. This console application is launched from a Windows application which passes parameters to it when it starts (in the form of command-line-switches). I have no problem detecting Windows executables, but I can't seem to be able to detect when a small, minimized (i.e. no window pops up when it runs) program executes. This program can execute and close in as little as a second or two, so I need to catch it quickly. Alternatively, if there was a way I could read some kind of record that listed all of the programs/processes that had been run in the last 10 seconds (or any suitable time period) that would be even better, because then I could make my program a lot less resource intensive. Bonus points go to anybody who can show me how to detect that the program has run AND intercept any parameters (switches) that were passed to it!



Thanks in advance for all your help.
I really appreciate it.

Regards,

Peter
Reply With Quote
  #2  
Old 11-08-2005, 11:22 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,688
Default

1) RegOpenKeyEx, RegQueryValueEx, RegSetValueEx, RegCloseKey

2) First check the obvious, the file size FileLen/LOF. Next calculate the CRC32 of each (my routine processes at 30-50 megs/second on a fast HD). There is a small chance (1 in 65536 or so)) that a CRC32 of two different files could be the same. So you could also use a long by long (then byte by byte for any trailing bytes) comparison of the file loaded into an array.

3) hmmm.. Might consider FindWindow and the classname for a console.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #3  
Old 11-08-2005, 11:28 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,688
Default

If you used the snapshot APIs, you could get a list of the currently running processes. Then check the exe type with GetBinaryType API. Unfortunately this requires polling, as there's no notification of consoles, that I know of...
__________________
Quis custodiet ipsos custodues.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->