?
Solved

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

Posted on 2010-11-24
8
Medium Priority
?
3,561 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
[X]
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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
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: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

771 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