前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于PowerBuilder的搜索

c++ - Calling external function from DLL with PowerBuilder 10.0 error - Stack Overflow Explore our sites chat blog Stack Overflow Meta Stack Overflow Careers 2.0 Stack Exchange sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site careers 2.0 Stack Overflow Questions Tags Tour Users Ask Question Take the 2-minute tour × Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required. Calling external function from DLL with PowerBuilder 10.0 error up vote 0 down vote favorite I have created a DLL using Visual C++ 2008 that creates two external functions. Using python I have created two separate executable functions to run these. When using PowerBuilder to call the function, the first executable runs fine. The second executable results in a runtime error: error calling external function %s``. I use a.def` file and have the correct ordinals for each function. Any advice? The function declarations in C are as follows (sorry they are quite long): extern "C" int __stdcall start_proctor( double points[], double weights[], double opoints[], double &SG, char sg_estimated[], double &smooth, char ptitle[], double &pheight, double &pwidth, char save_location[], int &show, int &ZV, char roundM[], char roundD[], int &zoom, char cwd[], int &x_scale_major_tick,int &y_scale_major_tick, char points_of[], char points_color[], char points_type[], int &points_size, char curve_of[], char curve_color[], int &curve_alpha, int &curve_size, char grid_of[], char grid_color[], int &grid_alpha, int &grid_x_dash, int &grid_y_dash, char opt_of[], char opt_color[], int &opt_alpha, int &opt_x_dash, int &opt_y_dash, int &x_scale_major_tick_c, int &y_scale_major_tick_c, char points_of_c[], char points_color_c[], char points_type_c[], int &points_size_c, char curve_of_c[], char curve_color_c[], int &curve_alpha_c, int &curve_size_c, char grid_of_c[], char grid_color_c[], int &grid_alpha_c, int &grid_x_dash_c, int &grid_y_dash_c, char opt_of_c[], char opt_color_c[], int &opt_alpha_c, int &opt_x_dash_c, int &opt_y_dash_c, int &return_default, int &splash, double &optmoisture, double &maxdd, double &percent_oversized, double &o_SG , double &o_moisture, double &o_optmoisture, double &o_maxdd, int &oversized_flag, int &debug, char c_output[] ); extern "C" int __stdcall start_grain_size( char dsn_name[], char userID[], char passwd[], double test_data[], int &td_length, double upper_bound[], int &ub_length, double lower_bound[], int &lb_length, char envelope[], char specification[], char pointmarker[], char splinemarker[], char display[], char scale[], char units[], char xlabel[], char direction[], char maximum_density_line[], int &pan, char title[], char save_location[], char cwd[], int &show, double &width, double &height, char output[] ); In PowerBuilder the external function declarations are: Function int start_proctor(ref double points[3,8], ref double weigthts[8], ref double opoints[3,8], ref double sg, ref string sg_estimated, ref double smooth, ref string ptitle, ref double pheight, ref double pwidth, ref string save_location, ref int show, ref int zv, ref string roundm, ref string roundd, ref int zoom, ref string cwd, ref int li_x_scale_major_tic, ref int li_y_scale_major_tic, ref string ls_points_of, ref string ls_points_color, ref string ls_points_type, ref int li_points_size, ref string ls_curve_of, ref string ls_curve_color, ref int li_curve_alpha, ref int li_curve_size, ref string ls_grid_of, ref string ls_grid_color, ref int li_grid_alpha, ref int li_grid_x_dash, ref int li_grid_y_dash, ref string ls_opt_of, ref string ls_opt_color, ref int li_opt_alpha, ref int li_opt_x_dash, ref int li_opt_y_dash, ref int li_x_scale_major_tic_t, ref int li_y_scale_major_tic_t, ref string ls_points_of_t, ref string ls_points_color_t, ref string ls_points_type_t, ref int li_points_size_t, ref string ls_curve_of_t, ref string ls_curve_color_t, ref int li_curve_alpha_t, ref int li_curve_size_t, ref string ls_grid_of_t, ref string ls_grid_color_t, ref int li_grid_alpha_t, ref int li_grid_x_dash_t, ref int li_grid_y_dash_t, ref string ls_opt_of_t, ref string ls_opt_color_t, ref int li_opt_alpha_t, ref int li_opt_x_dash_t, ref int li_opt_y_dash_t, ref int li_return_default, ref int li_splash, ref double optmoisture, ref double maxdd, ref double pover, ref double osg, ref double om, ref double o_optmoisture, ref double o_maxdd, ref int oversized_flag, ref int debug_flag, ref string output) LIBRARY "ELMTREE_EXTERNAL.dll" ALIAS FOR "start_proctor;ansi" Function int start_grain_size(ref string dsn_name, ref string userid, ref string passwd, ref double test_data[], ref int td_length, ref double upper_bound[], ref int ub_length, ref double lower_bound[], ref int lb_length, ref string envelope, ref string specification, ref string pointmarker, ref string splinemarker, ref string display, ref string scale, ref string units, ref string xlabel, ref string direction, ref string maximum_density_line, ref int pan, ref string title, ref string save_location, ref string cwd, ref int show, ref double width, ref double height, ref string output) LIBRARY "ELMTREE_EXTERNAL.dll" ALIAS FOR "start_grain_size;ansi" start_grain_size results in the error c++ dll PowerBuilder python-c-api share|improve this question edited Mar 22 '13 at 14:17 Seki 5,07621527 asked Aug 31 '11 at 16:50 James Hall 32 Impossible to say what the problem is based on the information here. – David Heffernan Aug 31 '11 at 19:09 Please add your function declarations in C and the corresponding external function declarations in PowerBuilder. – Hugh Brackett Aug 31 '11 at 21:22 Just to be clear, which of the functions results in an error? – Hugh Brackett Oct 24 '11 at 15:28 @Hugh Brackett--start_grain_size results in the error – James Hall Oct 25 '11 at 14:55 add comment 2 Answers active oldest votes up vote 0 down vote I don't see anything wrong with the PB code. I think your error is in the C code that's calling Python. You may not be setting the name of the function you want to invoke correctly. That's what the %s in the error message suggests. I tagged this question for python-c-api to try to attract a few gurus. They will doubtless want to see your C code that's calling Python. share|improve this answer answered Oct 25 '11 at 20:58 Hugh Brackett 2,131414 add comment up vote 0 down vote I'm going to try a wild guess (not really enough information yet to be sure), and say that the PB app is having difficulty locating the DLL in question. You can confirm this by using Process Monitor to watch your PB app (make sure you set the filter so that the Process Name matches your app, or you'll get a flood of info, although you can filter after the fact) and watch for any failures accessing the DLL on the failure case. It could be something like a current directory is being changed, and location of the DLL had been depending on that link in the search chain. If that is the case, I'd recommend creating an App Path for your application, which includes the path of your application, even if it is only the folder containing your EXE. IME, it has solved problems like these. Good luck, Terry. share|improve this answer answered Mar 22 '13 at 15:58 Terry 4,892613 It's in the same DLL as the function that works. It's a shame PB doesn't build and compile C++ any more. Back in the old days you could trace right into the dispatch and marshalling code and on into the function. You can still attach to the process. Determining the memory address to set the breakpoint is left as an exercise for the reader. My guess is that PB doesn't like something about one of the variables that are being passed. – Hugh Brackett Mar 22 '13 at 17:47 I'm not saying the DLL is the problem. It could be that the first call to the DLL is successful, because it depends on some element in the Windows DLL search algorithm that is transient like current directory. If something between the two calls changes the current directory, a DLL that could be found the first time might go "missing" the second. I've seen that more than once before. – Terry Mar 25 '13 at 14:22 add comment Your Answer draft saved draft discarded Sign up or login Sign up using Google Sign up using Facebook Sign up using Stack Exchange Post as a guest Name Email required, but not shown Post as a guest Name Email required, but not shown discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged c++ dll PowerBuilder python-c-api or ask your own question. tagged c++ × 259232 dll × 11076 PowerBuilder × 593 python-c-api × 265 asked 2 years ago viewed 2202 times active 10 months ago Community Bulletin blog Stack Exchange Creative Commons data now hosted by the Internet Archive Related 0 How do I call a Pb generated native Win32 dll from .Net? Or from anywhere else? 3 extern “C” DLL: Debug is OK, Release throws Error C2059 1 PowerBuilder application call the Delphi DLL 1 Importing a DLL and using an extern function in C++ 0 how do I use C# dll in PowerBuilder? 0 Linker error trying to call extern “C” function from dll 2 External “Hello World” Function in SQL Anywhere with PowerBuilder-generated DLL 1 PowerBuilder implementing SFTP functionality 0 How to use a .NET DLL in PowerBuilder 9 1 How to pass a pointer from C# to native function in DLL? Hot Network Questions Why are chips safer than magnetic stripes? What do you call unclean water that you can't see through? Multi-line options with the `\usepackage` command All Your Base Are Belong To Us (Restricted) Unhate-able Villians Is Facebook coming to an end? Is there a word for being so polite so as to appear insincere? The Quickest Fox in the East How do you tell a friend they are not qualified? TikZ: Drawing regular hexagons with pictures inside Is the term 'field' too technical when giving messages on a form? What can be done to properly re-enable the Windows Firewall on a domain? How do I convince my students that the choice of variable of integration is irrelevant? Draw the Olympic Games logo Why is there such a big difference between "Size" and "Size on disk"? How can I get a sense of how management treats their staff before joining a company? Is Earth That Was totally uninhabited? How does Fuse work? How do I explain to a 6 year old why people on the other side of the Earth don't fall off? String Format descriptive text How to replace plus sign by comma Side to side sum+product of matrices What is the best way to turn down a Postdoc offer? Why we consider Lebesgue spaces for p greater than and equal to 1 only? more hot questions question feed lang-cpp about help badges blog chat data legal privacy policy jobs advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation Science Other Stack Overflow Server Fault Super User Web Applications Ask Ubuntu Webmasters Game Development TeX - LaTeX Programmers Unix & Linux Ask Different (Apple) WordPress Answers Geographic Information Systems Electrical Engineering Android Enthusiasts Information Security Database Administrators Drupal Answers SharePoint User Experience Mathematica more (14) Photography Science Fiction & Fantasy Seasoned Advice (cooking) Home Improvement more (13) English Language & Usage Skeptics Mi Yodeya (Judaism) Travel Christianity Arqade (gaming) Bicycles Role-playing Games more (21) Mathematics Cross Validated (stats) Theoretical Computer Science Physics MathOverflow more (7) Stack Apps Meta Stack Overflow Area 51 Stack Overflow Careers site design / logo © 2014 stack exchange inc; user contributions licensed under cc by-sa 3.0 with attribution required rev 2014.1.23.1324 Stack Overflow works best with JavaScript enabled