QLocalServer with Win32 pipe
-
What I'd like to achieve:
I'm trying to develop a memory pipe server which will be in Qt (QLocalServer) and client in C++ win32.
I've used an example source on QLocalSocket and QLocalServer to ensure my server is working correctly.What I've tried:
Here is the client source for the memory pipe.
@
cIPC_t::cIPC_t(char *szPipeName)
{
this->hPipe = 0;
strcpy_s(this->szPipeName, "\\.\pipe\");
strcat_s(this->szPipeName, szPipeName);
}bool cIPC_t::connect(void)
{
hPipe = CreateFileA(this->szPipeName, GENERIC_READ | GENERIC_WRITE, NULL, NULL, OPEN_EXISTING, 0, NULL);
cout << "CreateFile. " << GetLastError() << "\n";
bool boRet = false;
return boRet;
}bool cIPC_t::send(char *szMessage)
{DWORD dwWrittenBytes = 0;
if(WriteFile(hPipe, reinterpret_cast<LPCVOID>(szMessage), strlen(szMessage)+1, &dwWrittenBytes, NULL) == 0)
{
cout << "send. Error " << GetLastError() << "\n";
CloseHandle(hPipe);
return true;
}CloseHandle(hPipe);
return false;
}int main(void)
{
cIPC_t IPC("Client2");
IPC.connect();
IPC.send("HelloWorld");
}@
There are no errors according the GetLastError().
The server memory pipe is called "Client2" the packet is received on my server but the message length is 0.Thanks for reading. Would be grateful if anyone had any suggestions or tips.
Regards,
Paul -
Hi,
Can you also post your server code?
-
Look the catchcopy explorer plugin code, I have do that's.