Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:32:45+00:00 2026-05-20T06:32:45+00:00

Can anyone give an example of how a string can be returned from a

  • 0

Can anyone give an example of how a string can be returned from a call using Win32::API() function? I need to return a string and print using $val. Please give an example if the same can be handled using pointer as return type.

use Win32::API;  
my $res = new Win32::API('abc.dll','MyFun','_argument type list_','_Return type list_')or die $^E;  
my $val= $res->Call();   
print ($val);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:32:45+00:00Added an answer on May 20, 2026 at 6:32 am

    The documentation for Win32::API‘s Call() method suggests that you must pass Call() a scalar which will be used as a buffer to store the returned value; Call() itself will return whether the call succeeded or not.

    Example:

    my $return_buffer = " " x 80;
    if ($res->Call(80, $return_buffer)) {
        print "OK, the API call returned '$return_buffer'\n";
    } else {
        print "The API call failed for some reason.\n";
    }
    

    EDIT: quoting from the docs for completeness:

    The two parameters needed here are the length of the buffer that will hold the returned temporary path, and a pointer to the buffer itself. For numerical parameters, you can use either a constant expression or a variable, while for pointers you must use a variable name (no Perl references, just a plain variable name). Also note that memory must be allocated before calling the function, just like in C. For example, to pass a buffer of 80 characters to GetTempPath(), it must be initialized before with:

    $lpBuffer = " " x 80;
    

    This allocates a string of 80 characters. If you don’t do so, you’ll probably get Runtime exception errors, and generally nothing will work. The call should therefore include:

    $lpBuffer = " " x 80;
    $GetTempPath->Call(80, $lpBuffer);
    

    And the result will be stored in the $lpBuffer variable. Note that you don’t need to pass a reference to the variable (eg. you don’t need \$lpBuffer), even if its value will be set by the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone give me a complete list of string manipulation function in Microsoft SQL
I want to print the first 10000 prime numbers. Can anyone give me the
Can anyone give me an example (or point me in the right direction) on
Can anyone give me pointers to good books or web sites that teach how
Can anyone give me details of runtime error 3734 in Access vba. For reference
Can anyone give a concise set of real-world considerations that would drive the choice
Can anyone give me a scenario where they think busy cursors are justified? I
Can anyone give me an idea how can we show or embed a YouTube
Can anyone give an idea of how should I implement undo/redo of cutting/copying/pasting of
Are there some help resources, or can anyone give me a brief Idea how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.