Solved

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

Posted on 2010-11-24
8
3,285 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
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.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

914 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now