<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Speicher schnell allozieren]]></title><description><![CDATA[<p>Hi</p>
<p>Ich speichere folgendermassen Clipboardeinträge temporär:</p>
<pre><code class="language-cpp">void SaveClipboardData(void){

	OpenClipboard(NULL);

	int cf = 0;

	cf = CountClipboardFormats(); 

	for ( int i = 0; i &lt; cf; ++i ) {

		UINT f = EnumClipboardFormats(f);

		//printf(&quot;format: %i \n&quot;,f);

		HGLOBAL hMem = GetClipboardData(f);

		void * pMem = GlobalLock(hMem);

		// Backup

		HGLOBAL bMem = GlobalAlloc(GMEM_DDESHARE,GlobalSize(hMem));

		void * bpMem = GlobalLock(bMem);

		CopyMemory(bpMem, pMem, GlobalSize(hMem));

		GlobalUnlock(pMem);

		GlobalUnlock(bMem);

		data[i] = bMem;
		fs[i] = f;
		max = i;

	}

	CloseClipboard();

}

void LoadClipBoardData(void){

	OpenClipboard(NULL);

	EmptyClipboard();

	for ( int l = 0; l &lt; max; ++l ){
		SetClipboardData(fs[l],data[l]);
		//LPSTR formatname = new char[256];
		//if ( GetClipboardFormatName(fs[l],formatname,256) == 0 ){
		//	formatname = &quot;Unbekannt&quot;;	
		//}
		//printf(&quot;%s \t\t\t %i kb\n&quot;,formatname,GlobalSize(data[l])/1024);
	}

	CloseClipboard();

}
</code></pre>
<p>Bei grossen Daten ist diese Methode extrem langsam. Deshalb dachte ich an die Verwendung von VirtualAlloc. Ich weiss jedoch nicht wie man VirtalAlloc mit GlobalLock verwendet.</p>
<p>MfG Joe</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/155813/speicher-schnell-allozieren</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Jul 2026 11:24:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/155813.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 Aug 2006 20:18:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Speicher schnell allozieren on Wed, 09 Aug 2006 20:18:50 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>Ich speichere folgendermassen Clipboardeinträge temporär:</p>
<pre><code class="language-cpp">void SaveClipboardData(void){

	OpenClipboard(NULL);

	int cf = 0;

	cf = CountClipboardFormats(); 

	for ( int i = 0; i &lt; cf; ++i ) {

		UINT f = EnumClipboardFormats(f);

		//printf(&quot;format: %i \n&quot;,f);

		HGLOBAL hMem = GetClipboardData(f);

		void * pMem = GlobalLock(hMem);

		// Backup

		HGLOBAL bMem = GlobalAlloc(GMEM_DDESHARE,GlobalSize(hMem));

		void * bpMem = GlobalLock(bMem);

		CopyMemory(bpMem, pMem, GlobalSize(hMem));

		GlobalUnlock(pMem);

		GlobalUnlock(bMem);

		data[i] = bMem;
		fs[i] = f;
		max = i;

	}

	CloseClipboard();

}

void LoadClipBoardData(void){

	OpenClipboard(NULL);

	EmptyClipboard();

	for ( int l = 0; l &lt; max; ++l ){
		SetClipboardData(fs[l],data[l]);
		//LPSTR formatname = new char[256];
		//if ( GetClipboardFormatName(fs[l],formatname,256) == 0 ){
		//	formatname = &quot;Unbekannt&quot;;	
		//}
		//printf(&quot;%s \t\t\t %i kb\n&quot;,formatname,GlobalSize(data[l])/1024);
	}

	CloseClipboard();

}
</code></pre>
<p>Bei grossen Daten ist diese Methode extrem langsam. Deshalb dachte ich an die Verwendung von VirtualAlloc. Ich weiss jedoch nicht wie man VirtalAlloc mit GlobalLock verwendet.</p>
<p>MfG Joe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1114105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1114105</guid><dc:creator><![CDATA[*JoE*]]></dc:creator><pubDate>Wed, 09 Aug 2006 20:18:50 GMT</pubDate></item><item><title><![CDATA[Reply to Speicher schnell allozieren on Thu, 10 Aug 2006 13:30:38 GMT]]></title><description><![CDATA[<p>Hi,</p>
<blockquote>
<p>Deshalb dachte ich an die Verwendung von VirtualAlloc.</p>
</blockquote>
<p>Und wieso sollte das dann schneller gehen ?! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1114609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1114609</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 10 Aug 2006 13:30:38 GMT</pubDate></item><item><title><![CDATA[Reply to Speicher schnell allozieren on Thu, 10 Aug 2006 15:42:45 GMT]]></title><description><![CDATA[<p>Hmm ich habe das ganze mal folgendermassen umgeschrieben:</p>
<pre><code class="language-cpp">if (OpenClipboard(NULL) == 0)
		printf(&quot;\n open cl failed!&quot;);

	int cf = 0;

	cf = CountClipboardFormats(); 

    int f;

	HGLOBAL data[100];
	UINT fs[100];

    memset(data,0,sizeof(data));
    memset(fs,0,sizeof(fs));

    int i;

	for ( i = 0; i &lt; cf; ++i ) {

		f = EnumClipboardFormats(f);

		if (f != 0 &amp;&amp;  f== 49298  )
		{
			printf(&quot;\n format: %d \n&quot;,f);

			printf(&quot;get data\n&quot;);

			HGLOBAL hMem = GetClipboardData(f);
			//GlobalLock(hMem);

			if (hMem == NULL)
				printf(&quot;\n hMem = NULL&quot;);

			ULONG size = GlobalSize(hMem);

			printf(&quot;\n Size: %d kb&quot;,size);

			HGLOBAL bMem = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);

			printf(&quot;\n %X %i&quot;,bMem,f);

			CopyMemory(bMem, hMem, size );
			//GlobalUnlock(bMem);

			data[i] = bMem;
			fs[i] = f; 
		}
	}

	EmptyClipboard();

	Sleep(5000);

	for ( int l = 0; l &lt; i; ++l ){

		if (data[l] != 0 &amp;&amp; fs[l] != 0)
		{
			if (SetClipboardData(fs[l],data[l]) == NULL)
                 printf(&quot;\n setclipboard failed!&quot;);

			char * formatname = (char*)malloc(256);
			if ( GetClipboardFormatName(fs[l],formatname,256) == 0 ){
				formatname = &quot;Unbekannt&quot;;	
				printf(&quot;\n %s&quot;,formatname);
			}

		}
	}

	CloseClipboard();
</code></pre>
<p>Nur bei einer grossen Menge Daten (RTF) dauert GetClipboardData() einfach ewigs. Die Speicherauslastung bildet dann eine Zitterlinie und die CPU Auslastung ist 100%. Ich habe nach Informationen gesucht, jedoch nichts gefunden, wie man das Clipboard bei grossen Daten sinvoll und effizients nutzt. Zudem weiss ich nicht, wie genau zum Beispiel, Word zu Word die Daten über das Clipboard transferiert (Grosse Datenmengen funktionieren problemlos).</p>
<p>MfG Joe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1114705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1114705</guid><dc:creator><![CDATA[*JoE*]]></dc:creator><pubDate>Thu, 10 Aug 2006 15:42:45 GMT</pubDate></item></channel></rss>