msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GetProcAddress not working in VB6 for me, Ideas? Full progr

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB WinAPI
Author Message
Paul Coene



Joined: 20 Feb 2008
Posts: 3

PostPosted: Wed Feb 20, 2008 5:17 pm    Post subject: GetProcAddress not working in VB6 for me, Ideas? Full progr Reply with quote

I can't get GetProcAddress to return anything but 0. The LoadLibrary
seems to work.

Full console app below:

---------------------------------------------------------------
Module Module1
Private Declare Auto Function LoadLibrary Lib "kernel32.dll" (ByVal ProcName As String) As Integer
Private Declare Auto Function GetProcAddress Lib "kernel32.dll" (ByVal ModuleHandle As Integer, ByVal ProcName As String) As Integer

Sub Main()
Dim ModuleHandle As Integer
Dim MethodPointer As Integer

ModuleHandle = LoadLibrary("kernel32")
If ModuleHandle = 0 Then
Console.WriteLine("Cannot open kernel32")
Else
Console.WriteLine("kernel32 opened")
End If

MethodPointer = GetProcAddress(ModuleHandle, "LoadLibrary")
If MethodPointer = 0 Then
Console.WriteLine("Cannot find proc LoadLibrary")
Else
Console.WriteLine("Found LoadLibrary")
End If

Console.ReadLine()


End Sub

End Module
---------------------------------------------------------------

Results:

kernel32 opened
Cannot find proc LoadLibrary

Why?
--

It's 3:30, why aren't you at work?
I.. I didn't feel like it.

Archived from group: microsoft>public>vb>winapi
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Wed Feb 20, 2008 3:25 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

Paul Coene wrote:
>I can't get GetProcAddress to return anything but 0.

You'd have better hope for finding a solution here if you upgraded to VB6.
--
..NET: It's About Trust!
http://vfred.mvps.org
Back to top
View user's profile Send private message
Paul Coene



Joined: 20 Feb 2008
Posts: 3

PostPosted: Wed Feb 20, 2008 5:32 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

On Wed, 20 Feb 2008 10:25:05 -0800, Karl E. Peterson wrote:

> Paul Coene wrote:
>>I can't get GetProcAddress to return anything but 0.
>
> You'd have better hope for finding a solution here if you upgraded to VB6.

I'm using VS 2005 .NET. Isn't that like VB8? I'm new to the
windows development world - well sort of. Did I mislead?

--

It's 3:30, why aren't you at work?
I.. I didn't feel like it.
Back to top
View user's profile Send private message
Thorsten Albers



Joined: 04 Oct 2007
Posts: 756

PostPosted: Wed Feb 20, 2008 3:39 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

Paul Coene schrieb im Beitrag
...
> I can't get GetProcAddress to return anything but 0. The LoadLibrary
> seems to work.
> ---------------------------------------------------------------
> Module Module1
> Private Declare Auto Function LoadLibrary Lib "kernel32.dll" (ByVal
ProcName As String) As Integer
> Private Declare Auto Function GetProcAddress Lib "kernel32.dll"
(ByVal ModuleHandle As Integer, ByVal ProcName As String) As Integer
>
> Sub Main()
> Dim ModuleHandle As Integer
> Dim MethodPointer As Integer

a) Your code isn't VB 'classic' code! This newsgroup is for VB <= 6.0 aka
'classic' only!

b) C/C++ 'int' is a 4 byte data type. VB 'Integer' is a 2 byte data type.
For C/C++ 'int' you have to use 'Long' in VB.

--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Wed Feb 20, 2008 3:46 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

Paul Coene wrote:
> On Wed, 20 Feb 2008 10:25:05 -0800, Karl E. Peterson wrote:
>
>> Paul Coene wrote:
>>>I can't get GetProcAddress to return anything but 0.
>>
>> You'd have better hope for finding a solution here if you upgraded to VB6.
>
> I'm using VS 2005 .NET. Isn't that like VB8? I'm new to the
> windows development world - well sort of. Did I mislead?

No, you were misled by evil marketeers. It's "like" VB in name only. Otherwise,
the two share almost nothing in common, most especially source code! You're using
the bastardized version. Would suggest you find a group with ".dotnet." in its
name. Sorry...
--
..NET: It's About Trust!
http://vfred.mvps.org
Back to top
View user's profile Send private message
Scott Seligman



Joined: 04 Oct 2007
Posts: 12

PostPosted: Wed Feb 20, 2008 4:00 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

Paul Coene wrote:
>
>I can't get GetProcAddress to return anything but 0. The LoadLibrary
>seems to work.

As others have pointed out, this newsgroup isn't appropriate for
managed code questions. Nevertheless, I'll take a stab at answering
it:

>Private Declare Auto Function GetProcAddress Lib "kernel32.dll" (ByVal
>PrModuleHandle As Integer, ByVal ocName As String) As Integer

You need to use "Ansi" instead of "Auto" here, since GetProcAddress
expects an ANSI string.

> MethodPointer = GetProcAddress(ModuleHandle, "LoadLibrary")

There is no function exported from kernel32.dll called "LoadLibrary".
Perhaps you meant "LoadLibraryW"?

--
--------- Scott Seligman and michelle dot net> ---------
The American Republic will endure, until politicians realize they can
bribe the people with their own money.
-- Alexis de Tocqueville
Back to top
View user's profile Send private message
Bob Butler



Joined: 04 Oct 2007
Posts: 1081

PostPosted: Wed Feb 20, 2008 4:23 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

"Thorsten Albers" wrote in message $ba7ea8a0$9f01a8c0@xyz...
> Paul Coene schrieb im Beitrag
> ...
>> I can't get GetProcAddress to return anything but 0. The LoadLibrary
>> seems to work.
>> ---------------------------------------------------------------
>> Module Module1
>> Private Declare Auto Function LoadLibrary Lib "kernel32.dll" (ByVal
> ProcName As String) As Integer
>> Private Declare Auto Function GetProcAddress Lib "kernel32.dll"
> (ByVal ModuleHandle As Integer, ByVal ProcName As String) As Integer
>>
>> Sub Main()
>> Dim ModuleHandle As Integer
>> Dim MethodPointer As Integer
>
> a) Your code isn't VB 'classic' code! This newsgroup is for VB <= 6.0 aka
> 'classic' only!
>
> b) C/C++ 'int' is a 4 byte data type. VB 'Integer' is a 2 byte data type.
> For C/C++ 'int' you have to use 'Long' in VB.

But B# 'Integer' is 4 bytes... just one of the many gratuitous changes
Back to top
View user's profile Send private message
Paul Coene



Joined: 20 Feb 2008
Posts: 3

PostPosted: Wed Feb 20, 2008 6:39 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

On Wed, 20 Feb 2008 11:00:32 -0800, Scott Seligman wrote:

> Paul Coene wrote:
>>
>>I can't get GetProcAddress to return anything but 0. The LoadLibrary
>>seems to work.
>
> As others have pointed out, this newsgroup isn't appropriate for
> managed code questions. Nevertheless, I'll take a stab at answering
> it:
>
>>Private Declare Auto Function GetProcAddress Lib "kernel32.dll" (ByVal
>>PrModuleHandle As Integer, ByVal ocName As String) As Integer
>
> You need to use "Ansi" instead of "Auto" here, since GetProcAddress
> expects an ANSI string.

That was the ticket.

I didn't see any newsgroups with .NET and VB in the name on our
distribution. Anyone have the names?

Thank you and sorry for the inappropriate post for this group.
Back to top
View user's profile Send private message
Thorsten Albers



Joined: 04 Oct 2007
Posts: 756

PostPosted: Wed Feb 20, 2008 6:21 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

Bob Butler schrieb im Beitrag
...
> But B# 'Integer' is 4 bytes... just one of the many gratuitous changes

I didn't talk of B#.

--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
Back to top
View user's profile Send private message
Dave O.



Joined: 04 Oct 2007
Posts: 580

PostPosted: Thu Feb 21, 2008 4:05 pm    Post subject: Re: GetProcAddress not working in VB6 for me, Ideas? Full p Reply with quote

"Paul Coene" wrote in message @bellsouth.net...
> I didn't see any newsgroups with .NET and VB in the name on our
> distribution. Anyone have the names?

microsoft.public.dotnet.languages.vb
microsoft.public.dotnet.languages.vb.upgrade
microsoft.public.dotnet.languages.vb.controls
microsoft.public.dotnet.languages.vb.data
microsoft.public.dotnet.general
microsoft.public.vsnet.general

Regards
Dave O.

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
GetProcAddress return How can you use the value returned by API function in VB 6? I'd like to get the address of function and then call it. Thanks, aw

run the function address i got from GetProcAddress hi, i am thinking to use a function from a DLL this is what i did already: Dim dllHandler As Long Dim funcAddr As Long dllHandler = & funcAddr = GetProcA

Any ideas how to start this? Hi All, One of my friends has child who he wold like to terminate from the wireless network at a specific time each evening. The Router settings allow him to manually terminate the IP and disconnect from the LAN however he would like this to be automated

DecryptFile API Problem (Error 997 - Overlapped I/O in Progr Hi Gurus I am trying to use EncryptFile and DecryptFile APIs on windows 2003 server (logged on as Admin). I can use EncryptFile with out any error but when I execute DecryptFile it gives me API error# 997 "Overlapped I/O operation is in progress" Here is

Any ideas on file mapping ?? I have created shared memory mappings using Win 32 API Now I need to know these file mappings along with the list of processes that have mapped this file-mapping object into their virtual memory. I need to do this through code. Please
Post new topic   Reply to topic    msvisual.com Forum Index -> VB WinAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group