• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3743
  • Last Modified:

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

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
adithya
Asked:
adithya
  • 4
  • 3
1 Solution
 
kmanoharnaikCommented:
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
 
adithyaAuthor Commented:
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
 
kmanoharnaikCommented:
Hi,

where did u place the dlls???

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


regards
msn
0
Technology Partners: 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!

 
adithyaAuthor Commented:
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
 
kmanoharnaikCommented:
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
 
adithyaAuthor Commented:
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
 
Harish VargheseProject LeaderCommented:
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
 
kmanoharnaikCommented:
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now