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 8546059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:55:53+00:00 2026-06-11T12:55:53+00:00

I have a solution that has a c++ dll project(MsgHook.cpp) with a function:- BOOL

  • 0

I have a solution that has a c++ dll project(MsgHook.cpp) with a function:-

BOOL f_closeSEB()
{
    logg(fp, "\n\n");
    //TerminateProcess(hPiProcess->hProcess,0);
    SendMessage(hWndCaller,WM_DESTROY,NULL,NULL);
    logg(fp, "   SEB exit sequence, destroy window\n");
    //logg(fp, "Leave LLKeyboardHook() and return -1\n\n");
    return -1;
}

I am trying to call this function from my c# web services project in the following way:-

using System.Runtime.InteropServices;

    namespace closeSEB
    {
        partial class closeSEBService
        {
            /// <summary> 
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;

            public enum commands
            {
                CloseIt=255
            }

            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }

            [DllImport("MsgHook.dll", SetLastError = true)]
            public static extern void runRTS(string serviceName);

             protected override void OnCustomCommand(int command)
            {
              base.OnCustomCommand(command);
              if (command == (int)commands.CloseIt)
              {
                //Code to call msghook closeSEB function
                  runRTS("closeSEBService");
                  f_closeSEB(); 
              }
            }
            #region Component Designer generated code

            /// <summary> 
            /// Required method for Designer support - do not modify 
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                // 
                // closeSEBService
                // 
                this.ServiceName = "Service1";

            }

            #endregion

        }
    }

But in the compiler, I am getting an error that the name f_closeSEB does not exit in current context. Is this not the correct way of calling the function defined in DLL file via C#?

  • 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-06-11T12:55:54+00:00Added an answer on June 11, 2026 at 12:55 pm

    You have to make sure of two things:

    1. Write the DLLImport correctly like in the examples shown below

      [DllImport(“MsgHook.dll”, SetLastError = true)]
      public static extern bool f_closeSEB();

    2. Make sure you compile the DLL “MsgHook.dll” for x86 or x64 according to the C# program needs. .NET supports any cpu but C++ does not, so make sure of the required type.

    for more information, please consider the MSDN article on Calling Win32 DLLs in C# with P/Invoke.

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

Sidebar

Related Questions

In my solution I have a DLL project, say Project1 , that owns a
I have inherited a reasonable sized ASP.net solution that has no automated tests. The
I have a solution that is being referenced by a MSBuild project. In the
We have a Visual Studio 2010 solution that has over 120 projects that reference
I have a console application project and library project (dll) in one solution. The
I have a dll project that references Microsoft.Practices.EnterpriseLibrary.Common.dll (= the dll ) from my
Let's say you have a class library project that has any number of supplemental
(Re-written for clarity) I have a multi-project solution that I am looking to convert
My C# WinForms solution has two projects. A DLL which is the main project
In my project I have a DLL for some WPF/XAML controls that need to

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.