Error Calling External Function S Powerbuilder
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 About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Calling external function from DLL with PowerBuilder 10.0 error up vote 2 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_
and SafetyAsset NetworkAsset Operations and MaintenanceCommerceOverviewSubscription Billing and Revenue ManagementMaster Data Management for CommerceOmnichannel CommerceFinanceOverviewAccounting and Financial CloseCollaborative Finance OperationsEnterprise Risk and ComplianceFinancial Planning and AnalysisTreasury and Financial Risk ManagementHuman ResourcesOverviewCore Human http://stackoverflow.com/questions/7260545/calling-external-function-from-dll-with-powerbuilder-10-0-error Resources and PayrollHuman Capital AnalyticsTalent ManagementTime and Attendance ManagementManufacturingOverviewManufacturing NetworkManufacturing OperationsResponsive ManufacturingMarketingOverviewMarket with Speed and AgilityUnique Customer ExperiencesReal-Time Customer InsightsR&D/EngineeringOverviewDesign NetworkDesign OrchestrationProject and Portfolio ManagementSalesOverviewCollaborative Quote to CashSales Force AutomationSales Performance https://scn.sap.com/thread/3473224 ManagementSelling Through Contact CentersServiceOverviewEfficient Field Service ManagementOmnichannel Customer ServiceTransparent Service Process and OperationsSourcing and ProcurementOverviewContingent Workforce ManagementDirect ProcurementSelf-Service ProcurementServices ProcurementStrategic Sourcing and Supplier ManagementSupply ChainOverviewDemand ManagementDemand NetworkLogistics NetworkManufacturing Planning and SchedulingResponse NetworkResponse and Supply ManagementSales, Inventory, and Operations PlanningTransportation ManagementWarehouse ManagementSustainabilityOverviewEnvironment, Health, and SafetyProduct Safety and Stewardship NetworkBrowse by IndustryAerospace and DefenseAutomotiveBankingChemicalsConsumer ProductsDefense and SecurityEngineering, Construction, and OperationsHealthcareHigh TechHigher Education and ResearchIndustrial Machinery and ComponentsInsuranceLife SciencesMediaMill ProductsMiningOil and GasProfessional ServicesPublic SectorRetailSports and EntertainmentTelecommunicationsTravel and TransportationUtilitiesWholesale DistributionBrowse Platform and TechnologyAnalyticsOverviewBusiness IntelligencePredictive AnalyticsGovernance, Risk, and ComplianceEnterprise Performance ManagementApplication Platform and InfrastructureOverviewApplication PlatformContent and Collab
the functions. For example, a call to SQLGetInfo should be changed to SQLGetInfoW. If the http://www.techno-kitten.com/Changes_to_PowerBuilder/New_in_PowerBuilder_10/PB10New_-_Unicode_Support/PB10New_-_Unicode_Related_Chan/PB10New_-_Calling_External_Fun/pb10new_-_calling_external_fun.html function passes a string as an argument or returns http://www.angelfire.com/home/jasonvogel/pb_prototyping_api_calls_in_powerbuilder.htm a string, you can use the same syntax in PowerBuilder 10 as in previous releases if the string uses Unicode encoding. For example: FUNCTION int MyMessageBoxW(int handle, string content, string title, int showtype) LIBRARY "user32.dll" ALIAS error calling FOR "MessageBoxW" If the string uses ANSI encoding use this syntax: FUNCTION returnval FuncName(args) LIBRARY "libraryname.dll" ALIAS FOR "FuncNameUnicode;ansi" For example: FUNCTION int MyMessageBoxA(int handle, string content, string title, int showtype) LIBRARY "user32.dll" ALIAS FOR "MessageBoxA;ansi" Use fully-qualified name Even if you use the default name error calling external for an ANSI function, you must always use the ALIAS keyword if you want to specify that the string uses ANSI encoding, because you must qualify the ALIAS with the ansi keyword. For example, the following declaration will not compile, because the function name is not present in the ALIAS statement: FUNCTION int MyANSIFunction(ref string mystring) LIBRARY "Mydll.dll" ALIAS FOR ";ansi" // bad code!This declaration uses an alias that is the same as the function name in the DLL, but the ALIAS keyword is required so that the compiler can recognize that the Unicode version of the function needs to be called: FUNCTION int MyANSIFunction(ref string mystring) LIBRARY "Mydll.dll" ALIAS FOR "MyANSIFunction;ansi" Web www.techno-kitten.com www.sybase.com
Technical Support compiled these technical tips as FaxLine document 44648 to enable PowerBuilder developers to translate standard Microsoft function calls into PowerBuilder syntax, and to empower developers to use any of the external API calls within their PowerBuilder environments. In this issue of Powerline, we've dedicated the entire space of our "Techical News" section to provide you with this important information. The FaxLine document has been annotated here so that each step in the process will be clear for PowerBuilder developers with varying degrees of experience. The following information will help you translate any Windows SDK call to a PowerBuilder API function call. It doesn't matter whether you're using PowerBuilder 4.0, 5.0, or 6.0 but there are important differences between the 16- and 32-bit versions, as we'll discuss below. Step 1: Converting an SDK Call to a PowerBuilder API Call. First you need to get the syntax that will be converted. This can be obtained from either a Windows API Bible or the MSDN (Microsoft Developers Network). Step 2: Determining Whether it is a Function or a Subroutine. Function calls return a value; subroutines do not. Here is an example of a Microsoft function: BOOL GetFileVersionInfo( LPTSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData ); Here is an example of a Microsoft subroutine: VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer) Step 3: Converting the Data Types from Microsoft to PowerBuilder. Most of the data types are listed above, but some may be missing. When in doubt, it's usually safe to assume that 16-bit data types are "unit" and 32-bit are "ulong", since they are the most common. *If the word "Callback" appears as a data type, it cannot be performed within PowerBuilder. Callback routines are functions that are called from within functions. Step 4: Declaring a Local or Global External Function. This is a Microsoft function: BOOL GetFileVersionInfo( LPTSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData ); The BOOL represents a boolean return code, which is translated to "Boolean" in PowerBuilder for both 16 and 32 bit. A LPTSTR means a pointer to a string (see Step 3). In PowerBuilder, simply use