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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:32:52+00:00 2026-06-11T16:32:52+00:00

I have created a service in Win7 using C#. Within that service I want

  • 0

I have created a service in Win7 using C#. Within that service I want to use the BlockInput function, which in Win7 it seems requires admin.

I set the serviceprocessorinstaller’s, account, username, and password to an admin account, within the code and the BlockInput doesn’t work. Note: under the service properties/logon tab it is set properly.

I then added a manifest for my service and set the requestedExecutionLevel to “requireAdministrator”. Yet the BlockInput still doesn’t want to work.

I tried moving the BlockInput down to the client level and then to a client wrapper but still it doesn’t want to work.

Running out of ideas…Any suggestions?

Start Edit Here:

Here is my manifest (or part of it, sorry formatting is terrible)
<assemblyIdentity version="1.0.0.0" name="BlockInputService.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>



    namespace BlockInputService
    {
       [ServiceContract(Namespace = "http://BlockInputService")]
       public interface IBlockInputTest
       {
          [OperationContract]
          void BlockInputMethod();
       }

       public class BlockInputTest : IBlockInputTest
       {
          private const string SOURCE = "BlockInputService";
          private const string LOGNAME = "Application";

          [return: MarshalAs(UnmanagedType.Bool)]
          [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
          public static extern bool BlockInput([In, MarshalAs(UnmanagedType.Bool)] bool fBlockIt);

          public void BlockInputMethod()
          {
             if (!EventLog.SourceExists(SOURCE))
             {
                EventLog.CreateEventSource(SOURCE, LOGNAME);
             }

             try
             {
                bool flag = BlockInput(true);
                EventLog.WriteEntry(SOURCE, "BlockInput(true) returned: " + flag);

                EventLog.WriteEntry(SOURCE, "Sleep for 5 sec");
                Thread.Sleep(5000);
             }
             catch (Exception ex)
             {
                EventLog.WriteEntry(SOURCE, ex.Message);
             }
             finally
             {
                bool flag = BlockInput(false);
                EventLog.WriteEntry(SOURCE, "BlockInput(false) returned: " + flag);
             }
          }
       }
    }


  • 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-11T16:32:54+00:00Added an answer on June 11, 2026 at 4:32 pm

    I moved on and used SetWindowsHookEx to capture WH_KEYBOARD_LL and WH_MOUSE_LL events.

    I tried everything I could think of to get the BlockInput to work. I still think I was just configuring my service wrong or something but I dont have time to worry about it anymore.

    Thanks.

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

Sidebar

Related Questions

I have created web service in php. Now I want call that web service
I have created windows service i have try to debug for that i use
I have created web service in c#.In that admin panel when admin edit file
I have created one service in my grails application. in that service 25 methods
I have created a service class for my network connection so that my app
I have created Web-Service in asp.net with c# . Now i want to pass
I have created a WCF service for uploading images , which accepts System.IO.Stream as
We have created a WCF service hosted in a windows service that handles Authentication
I have created a web service which is saving some data into to db.
I have created a web service which takes a username and password as parameters

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.