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
Solved

Application execution error (R0021) calling Global External Function frm PB 11.5

Posted on 2010-11-24
8
3,376 Views
Last Modified: 2013-12-26
I am using PB 11.5 and trying to call external function GetUsernameW
Tried declararing the function as
Public Function boolean GetUsernameW( ref string userID, ref ulong len ) library "ADVAPI32.DLL" Alias for "GetUsernameW"
Then called the function like the one below.

string  ls_temp
ulong   lul_value
boolean lb_rc
lul_value = 255
ls_temp = Space( 255 )
lb_rc = GetUserNameW( ls_temp, lul_value )

I get Application execution error (R0021).  Enclosing the screen shot.
Tried for GetUsernameA as well. The other external functions example GetModuleFileName in Kernel32.dll doesn't give any such errors. Please suggest what could be wrong.



error.JPG
0
Comment
Question by:adithya
  • 4
  • 3
8 Comments
 
LVL 2

Expert Comment

by:kmanoharnaik
ID: 34204103
Hi,

Canyou clear all the values in watch window when you try to debug?

i could not see what are the variables exist in watch window

please let me know if you have problem.

thanks
msn
0
 

Author Comment

by:adithya
ID: 34204205
Hi..
Am enclosing another screen shot for variable values during debug. I have not added anything in watch window. Is it anything to do with the path where dll is present?
error.JPG
0
 
LVL 2

Expert Comment

by:kmanoharnaik
ID: 34204223
Hi,

where did u place the dlls???

can you please place it in C:\WINDOWS\system32


regards
msn
0
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.

 

Author Comment

by:adithya
ID: 34204407
The dll's are in the same path as you have mentioned
Our powerbuilder source code is in E drive though. Will this impact?
Tried regenerating the objects .. still the problem persists.
0
 
LVL 2

Expert Comment

by:kmanoharnaik
ID: 34204426
Hi,

it doesnt give problem with PB installation drive as per my knowledge.

is this the case only with this DLL function or any?

thanks
msn

0
 

Author Comment

by:adithya
ID: 34204565
Hi..

I have problem with only that advapi32 dll. We have other dlls like Kerenel32.dll,shell32.dll,user32.dll which are working fine.
For example we had used the following extrenal function for kernel.dll
Public Function Integer GetModuleFileName( Integer hModule, REF String Filename, Integer Size) library 'Kernel32.dll
The advapi.dll is releted to Active directory.Probalbly because of this we are getting error? please give suggestions
can you please tell how to check active directory is active or not?
0
 
LVL 12

Accepted Solution

by:
Harish Varghese earned 500 total points
ID: 34213860
Hello Adithya,

Function name in Alias For clause is case-sensitive. GetUserNameW should have G, U, N and W letters capital.

Please change below code
Public Function boolean GetUsernameW( ref string userID, ref ulong len ) library "ADVAPI32.DLL" Alias for "GetUsernameW"

To
Public Function boolean GetUsernameW( ref string userID, ref ulong len ) library "ADVAPI32.DLL" Alias for "GetUserNameW"
0
 
LVL 2

Expert Comment

by:kmanoharnaik
ID: 34215313
hi,

I believe alias will be added when you migrate the source code from earlier versionto latest version.
And  I dont see the syntax was wrong in Aditya's code while calling, if it is a case sensitive in declaring alias name, it is wrong. i hope it works without alias if its not migrated source code.
Please let me know the response from Aditya if Harish suggetsion works out.

regards
msn
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

837 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