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

  • Home
  • SEARCH
  • 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 724689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:15:06+00:00 2026-05-14T06:15:06+00:00

I have a third-party (Win32) DLL, written in C, that exposes the following interface:

  • 0

I have a third-party (Win32) DLL, written in C, that exposes the following interface:

DLL_EXPORT typedef enum
{
  DEVICE_PCI = 1,
  DEVICE_USB = 2
} DeviceType;

DLL_EXPORT int DeviceStatus(DeviceType kind);

I wish to call it from Delphi.

How do I get access to the DeviceType constants in my Delphi code? Or, if I should just use the values 1 and 2 directly, what Delphi type should I use for the “DeviceType kind” parameters? Integer? Word?

  • 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-14T06:15:06+00:00Added an answer on May 14, 2026 at 6:15 am

    The usual way to declare the interface from an external DLL in C is to expose its interface in a .H header file. Then, to access the DLL from C the .H header file has to be #included in the C source code.

    Translated to Delphi terms, you need to create a unit file that describes the same interface in pascal terms, translating the c syntax to pascal.

    For your case, you would create a file such as…

    unit xyzDevice;
    { XYZ device Delphi interface unit 
      translated from xyz.h by xxxxx --  Copyright (c) 2009 xxxxx
      Delphi API to libXYZ - The Free XYZ device library --- Copyright (C) 2006 yyyyy  }
    
    interface
    
    type
      TXyzDeviceType = integer;
    
    const
      xyzDll = 'xyz.dll';
      XYZ_DEVICE_PCI = 1;
      XYZ_DEVICE_USB = 2;
    
    function XyzDeviceStatus ( kind : TXyzDeviceType ) : integer; stdcall; 
       external xyzDLL; name 'DeviceStatus';
    
    implementation
    end.
    

    And the you would declare it in the uses clause of your source code. And invoke the function this way:

    uses xyzDevice;
    
    ...
    
      case XyzDeviceStatus(XYZ_DEVICE_USB) of ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Win32 C++ Application using a handful of third-Party DLLs that is
I have a third party dll that I need to install to the GAC.
I have a third-party, closed source application that exports a COM interface, which I
I have a Visual C++ 9 Win32 application that uses a third-party library. When
I have a third-party DLL that depends on MSVCR80 and allocates resources that I
I have a third-party dll that I load into software that isn't mine, and
I have a third party dll, that is supposed to return machine name. Sometimes
I have a third-party product, a terminal emulator, which provides a DLL that can
I have third-party C code that writes data to a file. I want to
I have third party sites that link to some images on my site. The

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.