Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - dll in the wrong directory?!

dll in the wrong directory?!

Discuss PocketC for CE (including Desktop Edition)

Postby Cindy on Fri Jan 03, 2003 2:16 pm

The error 87 is displayed by the MsgBox after calling LoadLibrary().

libby = LoadLibrary("\windows\MyRAS.dll")
Fehler = GetLastError()
MsgBox CStr(Fehler)

So the Variable Fehler = 87

Cindy
Cindy
 
Posts: 19
Joined: Fri Dec 20, 2002 9:14 am
Location: Germany

Postby guy on Sat Jan 04, 2003 12:32 pm

I am at a loss as to how to help with this any more. It is clearly a very simple problem that could be resolved in a couple of minutes with "hands-on" to the particular development environment, but that is almost impossible to resolve via remote control. To call a function in a DLL from VB you simply tell it which DLL to use, what the entry point is called and what you want to call the function in your program. You do this with a Declare statement. VB loads the library with LoadLibrary(), gets the address of the function with GetProcAddress(), builds an argument list and calls the function.

Either VB can't load the library, or it can't find the function in it. You can test both bits by writing your own program that calls LoadLibrary() to load your library and GetProcAddress() to find your function. This should be a little stand-alone program and not part of your real program.

Since this is a PocketC forum, and not an EVB or EVC forum, I'll list a little bit of PocketC code that will do the test. It shouldn't be difficult to convert it into evb:

Code: Select all


// Standard headers


#include "/pocketc/winbase.h"
#include "/pocketc/winuser.h"

// Globals

HINSTANCE   ghMydll ;         // Instance handle of dll
FARPROC      glpfnMyRasDial ;      // Address of MyRasDial function

main() {


//   Get a handle to the library containing the entry points that we want to call


   ghMydll = LoadLibrary("MyRas.dll") ;


   if (ghMydll != NULL) {


      confirm("Loaded MyRas.dll library") ;


//      Lookup the addresses the function


      glpfnMyRasDial = GetProcAddress((HMODULE) ghMydll, "MyRasDial") ;


      if (glpfnMyRasDial != NULL) {
         confirm("Got proc address of MyRasDial: " + hex(glpfnMyRasDial)) ;
      } else {
         confirm("Couldn't find proc address of MyRasDial: " + GetLastError()) ;
      }

   } else {
      confirm("Couldn't load library: " + GetLastError()) ;
   }


//   Unload the library before exiting


   if (ghMydll) {

      FreeLibrary(ghMydll) ;
      confirm("Freed MyRas.dll library") ;
   }


}




My feeling is that perhaps you are trying to do something a little ambitious for your level of understanding.

Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Cindy on Mon Jan 06, 2003 7:29 am

I understand that you dont want to spend a lot of time for that.
So that is my last try: I created a brand new projekt with just one button on it. I restarted the PDA and copied the MyRas.dll in the Windows directory. I use that code and have still the Errors.

where is the differens to other programs you know?

cindy

Option Explicit
Public Declare Function MyRasDial Lib "\Windows\MyRAS.dll" (ByVal phone_number As String, ByVal domain As String, ByVal username As String, ByVal password As String) As Long

Public Declare Function MyRasHangUp Lib "\Windows\MyRAS.dll" () As Long

Public Declare Function LoadLibrary Lib "Coredll" Alias "LoadLibraryW" (ByVal lpLibFileName As String) As Long

Public Declare Function GetLastError Lib "coredll.dll" () As Long

Private Sub internet_Click()

Dim rc As Long
Dim szDomain As String
Dim szPhoneNumber As String
Dim szUserName As String
Dim szPassword As String
Dim libby As Long
Dim Fehler As Long

szPhoneNumber = "xxxx-yyyy"
szUserName = "aaaa"
szPassword = "bbbb"
szDomain = Chr(0)

libby = LoadLibrary("\Windows\MyRAS.dll")
Fehler = GetLastError()
MsgBox CStr(Fehler)
---------------------> 87 / Parameter is incorrect


rc = MyRasDial(szPhoneNumber, szDomain, szUserName, szPassword)
---------------------> Unable to load function MyRasDial

End Sub

Private Sub Form_OKClick()
App.End
End Sub
Cindy
 
Posts: 19
Joined: Fri Dec 20, 2002 9:14 am
Location: Germany

Postby guy on Mon Jan 06, 2003 9:27 am

What is the value of libby after the call to LoadLibrary() ?

You're still doing too much. Forget about putting the call to MyRasDial() in the program. Just write a program that calls LoadLibrary(), prints the result and prints GetLastError() if the result is 0.

If the result of the call to LoadLibrary() is not 0 then call GetProcaddress() for your MyRasDial function. Print the result of this call. If the result is 0 then call GetLastError() and print the result.

Don't put in the declares for your functions at all.
Don't put in the Dims for your variables.

Don't add any user interface components. Just write the equivalent of the PocketC program that I wrote. The confirm() function is the same as a MsgBox with just a string parameter (the same as you are using already to print Fehler.

Strip the program down to the barest minimum. There are only two places that there could be a problem:

1. The library can't load
2. The function that you're calling can't be found in the library.

The library won't load for one of the following reasons:

1. It's not there
2. Another library that it uses isn't there
3. It's built for the wrong version of Windows CE
4. It's built for the wrong platform
5. It's built for the wrong CPU
6. Another library that it uses has problems 3, 4 or 5 above



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Cindy on Mon Jan 06, 2003 9:48 am

I want to say thank you for your time.
I copied the code from the .cpp and created the .dll again, put the .dll in the windows directory, called it (just by declaration and call) and it worked fine. I don't know why and I don't know where the different was....but it works.

Thanks alot.
Cindy
Cindy
 
Posts: 19
Joined: Fri Dec 20, 2002 9:14 am
Location: Germany

Postby Vineets on Tue Apr 15, 2003 3:32 am

:)
Cindy,

This should resolve your problem. Basically all you need to do is to construct the eVC++ DLL correctly. Other things yoiu were doing were correct.

Code in eVC++ in <YOURDLLFILE>.h
*************
#ifdef <YOURDLLFILE>_EXPORTS
#define DLLEXPORT _declspec(dllexport)
#else
#define DLLEXPORT _declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C" {
#endif

DLLEXPORT int <YOURFUNCTION>();

#ifdef __cplusplus
}//end extern "C"
#endif


**********
Code in <YOURDLLFILE>.cpp
#include "stdafx.h"
#include "<yourDLLfile>.h"


int <yourfunction>()
{
return 50; //some dummy value
}
*************
Now compile this DLL & it will get loaded in your \WINDOWS directory in your PDA

Now for the eVB code
in your main form ,
*********
Public Declare Function <yourfunction> Lib "<yourDLLfile>.dll" () As Integer

*********
Now simply invoke thsi DLL
*****
Text3.Text = CStr(<yourfunction>())
*****

Should<font color="blue"></font id="blue"> work!!
Vineets
 
Posts: 2
Joined: Tue Apr 15, 2003 3:22 am

Postby Vineets on Tue Apr 15, 2003 3:33 am

:)
Cindy,

This should resolve your problem. Basically all you need to do is to construct the eVC++ DLL correctly. Other things yoiu were doing were correct.

Code in eVC++ in <YOURDLLFILE>.h
*************
#ifdef <YOURDLLFILE>_EXPORTS
#define DLLEXPORT _declspec(dllexport)
#else
#define DLLEXPORT _declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C" {
#endif

DLLEXPORT int <YOURFUNCTION>();

#ifdef __cplusplus
}//end extern "C"
#endif


**********
Code in <YOURDLLFILE>.cpp
#include "stdafx.h"
#include "<yourDLLfile>.h"


int <yourfunction>()
{
return 50; //some dummy value
}
*************
Now compile this DLL & it will get loaded in your \WINDOWS directory in your PDA

Now for the eVB code
in your main form ,
*********
Public Declare Function <yourfunction> Lib "<yourDLLfile>.dll" () As Integer

*********
Now simply invoke thsi DLL
*****
Text3.Text = CStr(<yourfunction>())
*****

Should<font color="blue"></font id="blue"> work!!
Vineets
 
Posts: 2
Joined: Tue Apr 15, 2003 3:22 am

Previous

Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 2 guests

cron