|
Socket is just an unstructured byte stream, so you can certainly pass the pointer address as bytes on to other end. You will have to marshal pointer into bytes @ sending end and unmarshal it back to pointer at receiving end. To unmarshal, the receiver must either share the same address space as the sender or be provided a proxy to the same address space.
Oh, does this start to sound like Remoting?
Yep, that is what this is. Remoting does provide means to make a process function pointers visible to another process and Remoting does involve Sockets and passing of pointers to class. (Okay Okay, they're called reference)
So, Study Remoting !!.
|
|
|
|
|
Sockets are just one of the many ways to communicate, especially across processes. It's technically possible to pass any pointer using a socket without regards to what it's pointing to.
But if you pass a raw pointer from one process to another (using whatever mechanism, not just sockets), it immediately becomes meaningless because pointers are not portable across processes.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
As others have stated, you could pass pointers, but they would be meaningless to the other program since he can't access the memory addresses of the other exe (unless, it's "shared memory", continue reading). Your best bet would be to either transfer all the bytes of the image being referenced (or object, using serialization or other similar methods) or if both programs are local, let the client know where to find the image.
One common form of inter-process communications (IPC) is using "shared memory"[^]. In this case, one application would set up a shared memory pool that others can access. This is typically done for applications that need to work extremely fast (and all have direct access to the shared memory location) and don't want the overhead (or need the flexibility) of other IPC options (such as sockets or pipes).
|
|
|
|
|
UPDATE:
This is within same process. In that case can i simply pass the pointer over socket?
Another catch here is, i need to encode all the data in a XML format before sending across the socket.
C++ Code:
CImage *pImage; //pImage hold the data
Inside XML:
&pImage
Can i do like this?
|
|
|
|
|
If it's within the same application, then yes... but if you're within the same application, why are you using a socket at all?
Sockets are used to enable communications across multiple applications, not within the same application (you could but that doesn't mean you should, it's a lot of overhead for nothing).
|
|
|
|
|
I am unsure why are you using sockets, and I feel that there may be better options to choose from if you're having just one process.
If you could explain the situation with the required information (see this post[^] for help on what information to include in your question), someone here might be able to offer you a good alternative.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
It's very interesting.
In my own opinion, it is possible but you need something.
First, Receiver process have to open Sender process(use OpenProcess api with PROCESS_VM_READ) with memory access authority.
Second, Sender process have to allocate class instance on allocated memory located on it's own process memory(I don't know about it but if you use Google, it will appears).
Solving these problems may be difficult and complicated but it is possible, I think.
|
|
|
|
|
Oh yeah, watch out for endian ness.
|
|
|
|
|
HI,
Can anyone help me to find out any sample application to export the CListView data or GridView data into Excel or .CSV format using MFC
Thanks
ASH
|
|
|
|
|
Go to the articles section and search there, you will find many suggestions.
Veni, vidi, abiit domum
|
|
|
|
|
How is the CListView populated? If you have access to the code that does this, then you could export to a CSV from there.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Hi Rajesh,
Any sample code is there? It will be gr8 if you can share.
Thanks,
sma
|
|
|
|
|
I don't have a sample code with me to share, but I will need to write it. However, that takes time and I'll do it if I see that you've put all the efforts that you can.
It will be easier for you to try my suggestion and come back here with specific problems that you encounter during your attempt.
Now to answer it, do you have the code which populates this list view? If so, you could easily insert code into in there to export this same data to a .CSV file.
If not that, you could also read the values off the list view and then export it to CSV. Where exactly are you stuck?
Take one step at a time, and I'll help you through it if you need.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
I have the code which will insert values into list view..Only I need to read the data from list view and export it to excel.
Thanks in Advance
|
|
|
|
|
If I'm missing something here, please correct me.
If you've the code which is inserting the actual values, you could use that same code to create a .CSV file, right? Why do you have to write into a list, and read the same data from the list again?
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
My problem is to how to open the .CSV file and how to write the data into it..
Any sample is appreciated..
Thanks for your reply..
|
|
|
|
|
OK, that makes the problem much simpler then.
With MFC, you could use CFile or a CStdioFile for this purpose. It's very easy, and here's a sample: http://www.codeproject.com/Messages/3136266/Re-Getting-string-from-a-Text-file.aspx[^]
The sample code reads data, but you could easily create the file, and write and read from it with the member functions of this class.
- Create the file by passing the appropriate arguments to the constructor. Example on this page: http://msdn.microsoft.com/en-us/library/7b61hcx0(v=vs.90).aspx[^]
- Write data into it using the WriteString[^] method.
When you create the file, make sure that the extension is .CSV and format your string correctly such that it's comma separated before writing it into the file. Let me know if you need any more help.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
It has two monitor, main and expand monitor.
The expand monitor in the top with higher resolution ratio, and the main minitor in the bottom.
But if I drag a window to the expand monitor and then double click to show maximium, it has problem, it cannot fill of the windows of the expand monitor? why ? It save the main monitor rectangle info, how to change it.
modified 15-Oct-13 5:13am.
|
|
|
|
|
yu-jian wrote: It has two monitor What does - your PC or something else? And, what does this have to do with C++?
Veni, vidi, abiit domum
|
|
|
|
|
I had resolved this problem,
Use EnumDisplayMonitors to judge which monitor the application is in.
And then set the new maxmium position for the application.
|
|
|
|
|
Hi,
I need to set the DisableProcessWindowsGhosting(VOID) function in an application developed in VC6.0
The problem is that Windows.h that comes with that old programming environment does not know this function yet. What do I have to include in order to get access to that function?
|
|
|
|
|
You need to upgrade to a later version of Visual Studio or Visual Studio Express.
Veni, vidi, abiit domum
|
|
|
|
|
The problem is that my app still has to support Windows NT 4.0
Additionally, I guess it is part of the latest platform SDK available for VC6, I just wonder how to configure my project settings correctly...
|
|
|
|
|
You could try getting a later version of the Windows SDK, but you would still need a down version of the app for NT 4.0.
Veni, vidi, abiit domum
|
|
|
|
|
DisableProcessWindowsGhosting() is supported with XP SP1 and later. If your app must support older Windows versions, you must check the version. You can use late binding by getting the function address with GetProcAddress()[^]:
typedef void (WINAPI* LPFN_DisableProcessWindowsGhosting)();
HINSTANCE hInst = ::GetModuleHandle(_T("User32"));
if (hInst)
{
LPFN_DisableProcessWindowsGhosting lpfnFunc =
(LPFN_DisableProcessWindowsGhosting)::GetProcAddress(hInst, "");
if (lpfnFunc)
lpfnFunc();
else
TRACE("DisableProcessWindowsGhosting() is not supported\n");
}
This will also solve your problem regarding the old SDK header files.
|
|
|
|