Skip to content

Instantly share code, notes, and snippets.

@CCInc
Created June 5, 2013 00:35
Show Gist options
  • Save CCInc/5710783 to your computer and use it in GitHub Desktop.
Save CCInc/5710783 to your computer and use it in GitHub Desktop.
void Initialize_RPC()
{
RPC_STATUS status;
// Uses the protocol combined with the endpoint for receiving
// remote procedure calls.
status = RpcServerUseProtseqEp(reinterpret_cast<RPC_WSTR>(L"ncacn_ip_tcp"), // Use TCP/IP protocol.
RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog queue length for TCP/IP.
reinterpret_cast<RPC_WSTR>(L"4747"), // TCP/IP port to use.
NULL); // No security.
// Registers the Example1 interface.
status = RpcServerRegisterIf2(
Example1_v1_0_s_ifspec, // Interface to register.
NULL, // Use the MIDL generated entry-point vector.
NULL, // Use the MIDL generated entry-point vector.
RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, // Forces use of security callback.
RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Use default number of concurrent calls.
(unsigned)-1, // Infinite max size of incoming data blocks.
RPC_S_OK); // Naive security callback.
// Start to listen for remote procedure
// calls for all registered interfaces.
// This call will not return until^
// RpcMgmtStopServerListening is called.
status = RpcServerListen(
1, // Recommended minimum number of threads.
RPC_C_LISTEN_MAX_CALLS_DEFAULT, // Recommended maximum number of threads.
FALSE); // Start listening now.
}
[STAThreadAttribute]
INT main(array<System::String ^> ^args)
{
Initialize_RPC();
m_desktopName = L"HiddenDesktop1";
m_desktop = CreateDesktop(m_desktopName, NULL, NULL, 0, AccessRights, NULL);
//SwitchDesktop(m_desktop);
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment