• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

I need a clear explanation about using the hook examples from vbAccelerator.

I downloaded all the hooking source code and examples from vbAccelerator.  When I try to run any of the  downloaded projects, I get numerous errors.

In my opinion, when a project is downloaded, it should run error free. These projects are referenced in solutions on this site.  So far no-one has used the code without difficulty.

What do I need to do to run these projects?

vbalWinHook6.vbp

pJournalRecordHook6.vbp

vbalWinHook6.vbp

Thanks,

Dovberman






0
Dovberman
Asked:
Dovberman
  • 6
  • 2
  • 2
  • +2
1 Solution
 
Shane Russell2nd Line Desktop SupportCommented:
Could you list these errors out please ! I mean are you missing any files such as ocx files, dll's or anything that should of come with the program, what about using regsvr32 to register the files if you have any other files ?

Other then that it would be very helpful if we knew what those errors were :)
0
 
DovbermanAuthor Commented:
Lets focus on pJournalRecordHook6.vbp which is supposed to be error free.

The 1st error I get when loading the vbp is "IWindowsHook cannot be public in this type of project. This item will be opened private."

The next error occurs when I click Ctrl-F5 to compile and run.

Compile Error: "User Defined type not defined"

The error points to Private m_tCWP As CWPSTRUCT in class module cJournalParam

CWPSTRUCT is found nowhere in the project.

Has anyone succesfully opened and run pJournalRecordHook6.vbp ?
0
 
GrahamSkanRetiredCommented:
Hear, hear!
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
List244Commented:
CWPSTRUCT:

Private Type CWPSTRUCT
        lParam As Long
        wParam As Long
        message As Long
        hwnd As Long
End Type


The 1st error I get when loading the vbp is "IWindowsHook cannot be public in this type of project. This item will be opened private."

That means you put a public declare where it can only be private. My guess is the code is SUPPOSED to be
in a module, try changing the "PUBLIC" to "PRIVATE".

Any other errors?
0
 
DovbermanAuthor Commented:
The problem is that the following code segment is missing from the project.

Private Type CWPSTRUCT
        lParam As Long
        wParam As Long
        message As Long
        hwnd As Long
End Type


What module or class module shoud I insert it into?

Missing and incorrect variable names and code segments are common in vbAccelerator.

I imagine that there will be more errors after this one is fixed.

Thanks,

Dovberman
0
 
List244Commented:
Public Type CWPSTRUCT
        lParam As Long
        wParam As Long
        message As Long
        hwnd As Long
End Type

Put that in a module. It seems you need a bit more experience with VB. The errors you
are getting are VERY basic, and easy to fix. I would suggest putting this aside and
practicing a little more basic VB before looking into this project.
0
 
DovbermanAuthor Commented:
I knew that the user defined type needed to be in a module.  

<<What module or class module shoud I insert it into?>>

I have 15 years experience as a VB applications developer.

See my site and product at http://www.pokeroddscalc.com

My software products do not have compile errors when they are released.
I would expect the same of vbAccellerator or any other publisher.

I created a standard module for CWPSTRUCT and the other 6 hooking types that were omitted, but are clearly described in the MSDN library.

The fix is simple, but should not have been necessary.

Please do not confuse disappointment with inexperience.

My reply would have been:

You need to create a standard module (not class module) named something like basHookUtils.

Insert the following code.

Public Type CWPSTRUCT
        lParam As Long
        wParam As Long
        message As Long
        hwnd As Long
End Type

You will need to add code to basHookUtils for other missing user defined types that the Compile Error points to.

You will find the code you need at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookstructures/cwpstruct.asp

Hope this helps,

Dovberman


0
 
EDDYKTCommented:
where do you download the code from? actual link
0
 
DovbermanAuthor Commented:
You cannot download the code from the msdn.  You need to copy the C-Language structure segment and convert it to VB.

typedef struct {
    LPARAM lParam;
    WPARAM wParam;
    UINT message;
    HWND hwnd;
} CWPSTRUCT

Change to:

Public Type CWPSTRUCT
        lParam As Long
        wParam As Long
        message As Long
        hwnd As Long
End Type

I just found a missing module:

When you download the project from vbAccelerator,

mWindowsHook.bas was download but not referenced in the project.
Add mWindowsHook.bas to the project.  This module has a lot of the missing code.

But Wait, that is not all.  The project will still not compile.
You get a type mismatch compile error in the frmJournalRecordHook form.

Private Sub Form_Load()
   enableUIControls False
   InstallHook Me, WH_JOURNALRECORD
End Sub

VB does not like either the Me form object passed to the InstallHook function.

InStallHook is a Public function in both mWindowsHook.bas and GHook.
I am not sure which InstallHook function is being called.

The code should specify this with ModuleName.FunctionName as in GHook.InstallHook
GHook simply forwards the call to the InStallHook function in mWindowsHook.

I need help fixing this part. It may be simple to someone else.

0
 
EDDYKTCommented:
>>When you download the project from vbAccelerator

What is the link
0
 
DovbermanAuthor Commented:
The link to vbAccelerator hook libraries is:

http://www.vbaccelerator.com/home/VB/Code/Libraries/Hooks/vbAccelerator_Hook_Library/article.asp

You will need to download both VB6 Windows Hook Library Binary and VB6 Windows Hook Library Full Source.

I am not sure it will work even after getting through the compile errors.  At this point, I am ready to write my own hook project.  I just thought I would save time by using existing code. I would probably not use 8 different class modules.

I hope that List244 has not given up.
0
 
DovbermanAuthor Commented:
I get a type mismatch compile error in the frmJournalRecordHook Load Event

Private Sub Form_Load()
   enableUIControls False
   InstallHook Me, WH_JOURNALRECORD
End Sub

This calls GHook.InstallHook

Public Function InstallHook( _
      ByVal IHook As IWindowsHook, _
      ByVal eType As EHTHookTypeConstants _
   ) As Boolean
   InstallHook = mWindowsHook.InstallHook(IHook, eType)
End Function

The user defined type, IWindowsHook is not found anywhere in the project.
Although my guess is that it should be defined in the IWindowsHook.cls module.

What do I need to do?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now