Click here to Skip to main content
15,850,917 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
In my MFC app, when I click button void CSecondDlg::BtnSearchUsers(), it will do this:
ShellExecute(nullptr,_T("open"),_T("rundll32.exe"),_T("dsquery.dll,OpenQueryWindow"), nullptr, SW_SHOWNORMAL); (it will go to this system dialog). When I click "Search" button, I see all local and domain users and groups. I want to make a code when I click one of the users. I want to show selected user name to edit control void CSecondDlg::EdtWichUser().

What I have tried:

I've tried to search in AI and tutorials from YT, but I didn't find any tutorials for this solution.
Posted
Updated 13-Sep-23 7:30am
v2

Using AI is largely a waste of time to solve programming issues, or research "how to" questions. Microsoft provides a comprehensive set of documentation that you should make use of.

Using ShellExecute runs the search in a separate Window. So there is no way you can click any of the items listed and get them into your dialog automatically. If you want to read the data into your application then you will need to use the API to access the records. See Dsquery.h header - Win32 apps | Microsoft Learn[^].
 
Share this answer
 
Comments
Andre Oosthuizen 31-Aug-23 4:59am    
Quote: Using AI is largely a waste of time to solve programming issues, or research "how to" questions. Microsoft provides a comprehensive set of documentation that you should make use of. - +5
Richard MacCutchan 31-Aug-23 5:02am    
Thanks. Although I don't expect my comment to make much difference to the ones who think AI has all the answers.
Andre Oosthuizen 31-Aug-23 5:08am    
Indeed, it probably won't, bringing up the Insider News article - Perhaps AI is going to take away coding jobs – of those who trust this tech too much[^]
Richard MacCutchan 31-Aug-23 5:51am    
Probably not in my lifetime.
Why would you want to launch an entirely separate process (rundll32) that will not communicate with your app at all? Using the query window will do nothing in your application. You app will never know the user did anything in that window because it's not part of your application.

What you're trying to do is a complete waste of time. You have to write the functionality you want into your own application, not shell out to some separate process.
 
Share this answer
 
You need to use API NetUserEnum and NetQueryDisplayInformation
NetUserEnum


NetQueryDisplayInformation 


and link with
Netapi32.lib
include
Lm.h


And with all that information you can populate you dialog's combo box.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900