none
Getting the state of a computer

    Question

  • Hi,

                      I don't know whether this is the right place to ask my question ? If not can you please reroute me to correct place.

                I'm developing a NFC(Near Field Communication) device based on a Arduino microcontroller board that act like a keyboard to the computer and type the password which is stored in a Proximity Inductive Coupling Card(PICC-A NFC card). Because of this device act as a keyboard, if someone use this device and the card in a notepad the stored password will be instantly typed in notepad. To avoid this I need something like this,

                        When Arduino board aske from the computer that "Is you locked and your username is this"

            The computer must reply to the Arduino board the answer and microcontroller will decide what to do next depend on the answer.

    I need to know that is such a communication possible? Is there any way that I can get the current state of the computer(Whether it's locked or not) ? Sorry for my terible English as it's not my first language.

                                 


    Hasitha Dilshan Dissanayaka

    • Moved by Bruce Eitman Friday, April 26, 2019 12:54 PM Not a Windows Compact question
    Friday, April 19, 2019 1:44 PM

All replies

  • Can you communicate over USB to a computer? Yes, of course you can.  USB.org has lots of information about it.

    Can you send a message to a computer to ask it about its state? Yes.


    Bruce Eitman
    Senior Enginer
    Bruce.Eitman AT Synopsys DOT com
    My BLOG http://geekswithblogs.net/bruceeitman
    I work for
    Synopsys

    Tuesday, April 23, 2019 4:39 PM
  • Dear Bruce Eitman,

                                        Thank you very much for the reply. But I want to how can I achieve this? I mean what API/Library I must use in this task. However I want skip the process of writing a computer program that'll be installed on the computer to help Arduino in this case, if possible.


    Hasitha Dilshan Dissanayaka


    Tuesday, April 23, 2019 6:53 PM
  • You have not told us enough for me to answer your questions or discuss possible solutions.

    Bruce Eitman
    Senior Enginer
    Bruce.Eitman AT Synopsys DOT com
    My BLOG http://geekswithblogs.net/bruceeitman
    I work for
    Synopsys

    Wednesday, April 24, 2019 4:26 PM
  • As this is an Arduino based question, you might be better to look in their forms for help.  forum.arduino.cc

    A search for Arduino and NFC there would probably find you more folks looking at the same scenario and hardware.  Also, as the NFC is likely an add-on you could reach out to the NFC part manufacturer for samples of how they expect it to be used.  

    Wednesday, April 24, 2019 5:15 PM
  • Hi,

                      I want to know about a C/C++  library/API that I can use to Identify whether a windows 10 pc is locked or not (If Possible current user name that I have to enter password). I'm not an experienced user and I don't know whether I'm asking a valid question either. But I think through out the years of experience people in here know such things. Actually at the current time I only have the idea and in  these days I'm trying to play with the NFC hardware and Arduino. I'll try to be more detailed as soon as I dig into this. In simple form what I want is when Arduino micro controller aske "Is you locked" from the computer, computer must reply back to micro controller. The micro controller will act like a typical USB device.

                                    If I waste your time asking a stupide undetailed question, I'm very sorry. But I'll try be more detailed as I go far on this project. Highly appreciate your help on this question and thank you vey much.


    Hasitha Dilshan Dissanayaka


    Wednesday, April 24, 2019 7:20 PM
  • Hi IoTGirl,

                                 Maybe you are right. I must aske this in the Arduino forum. What I want is a link between the Arduino and windows 10 OS. So the Arduino micro controller can know whether the Pc is locked or not.


    Hasitha Dilshan Dissanayaka


    Wednesday, April 24, 2019 7:22 PM
  • It certainly cant hurt to ask.  You are more likely to find someone with specific Arduino experience there as well.
    Thursday, April 25, 2019 8:30 PM
  • I want to know about a C/C++  library/API that I can use to Identify whether a windows 10 pc is locked or not 

    For windows 7 and above, WTS API can be used with WTSQuerySessionInformation:

    There is a sample method:

    #include <Wtsapi32.h>
    #pragma comment(lib, "Wtsapi32.lib")
    bool IsSessionLocked()
    {
    	WTSINFOEXW * pInfo = NULL;
    	WTS_INFO_CLASS wtsic = WTSSessionInfoEx;
    	bool bRet = false;
    	LPTSTR ppBuffer = NULL;
    	DWORD dwBytesReturned = 0;
    	LONG dwFlags = 0;
    	DWORD dwSessionID = WTSGetActiveConsoleSessionId();
    	if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, dwSessionID, wtsic, &ppBuffer, &dwBytesReturned))
    	{
    		if (dwBytesReturned > 0)
    		{
    			pInfo = (WTSINFOEXW*)ppBuffer;
    			if (pInfo->Level == 1)
    			{
    				dwFlags = pInfo->Data.WTSInfoExLevel1.SessionFlags;
    			}
    			if (dwFlags == WTS_SESSIONSTATE_LOCK)
    			{
    				bRet = true;
    			}
    		}
    		WTSFreeMemory(ppBuffer);
    		ppBuffer = NULL;
    	}
    	return bRet;
    }

    hope it helps.

    Best regards,

    Drake


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 8, 2019 7:56 AM