Is there any limit of the size of data that can be copied to clipboard? I am using VB6 and need to copy blocks of data to the clipboard.
|
migrated to stackoverflow.com by Diago Aug 24 '09 at 11:33
|
Depends on the amount of memory in the system. |
|||
|
|
Most data is copied as a reference rather than the data itself so you can copy most anything any size. Text though is actually copied and from what I know the amount of data is limited to how much ram is currently availiable. Remember this, if vb6 can handle it, I'm sure the clipboard can handle it. |
|||
|
|
|
To add something to the clipboard, you need to allocate memory for the data first, then pass a handle of this memory block to the clipboard. Because WIN32 applications are limited to 2 GB of memory, the amount of memory that you could allocate would be related to the size of RAM that's still available in your application. With the additional /3GB parameter in boot.ini, you could make this amount a bit bigger. And if your system has less than 2 GB of RAM, increasing the size of the swap file will also help to send up to 2 GB. Of course, the client application also needs to be able to use this data. Trying to fir 1500 MB of data in a process that only has 600 MB available will not work. But if you truly want to send huge blocks of data, use temporary files instead! One trick would be by using a COM interface. Create your own COM class first, which needs to wrap around the data, where the data should be file-based. Then create a temporary file and add your data to this file. Create a COM object which links to this temporary file and send the COM object over to the client. The client needs to be able to handle the COM object too but could then use it to extract the data from it again. This would theoretically provide you unlimited memory space. Drawback: you need to write a COM class and know what you're doing. Or use other techniques to send over the data. Named pipes, mailslots, TCP/IP... There are many alternative inter-process techniques to send data between two applications. Since you're using VB6, I won't start about .NET or WIN64 options. |
|||
|
|
