<?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[Optimieren von Funktion]]></title><description><![CDATA[<p>Hi Leute ich bin mir zwar nicht ganz sicher ob es das richtige Forum ist,<br />
aber ich schildere hier mal mein Problem:<br />
Ich habe eine Funktion geschrieben die mir den Inhal eines Verzeichnis ausgibt.<br />
Es ist in einem eigenen Thread arbeitet mir aber zu langsam! Wie kann ich das ändern (optimieren)?</p>
<pre><code class="language-cpp">Form5-&gt;ListView1-&gt;Items-&gt;Clear();
    WIN32_FIND_DATA filedata;
    AnsiString slVolumeName;
    DWORD dwVolumeSerial;
    HANDLE filehandle;
    SYSTEMTIME stcUTC,stLocal;
    DWORDLONG filesize;
    int pos,i=0;
    float size;
    String groesse,date,minute,hour,typ,dir=pfad;
    WORD nummer;
    TIcon *MyIcon = new TIcon();

    Form5-&gt;ListIcons-&gt;Clear();
    Form5-&gt;ListIcons-&gt;BkColor= (TColor)0x00FFFFFF;    //Transparenz
    Form5-&gt;LargeIcons-&gt;Clear();
    Form5-&gt;LargeIcons-&gt;BkColor= (TColor)0x00FFFFFF;    //Transparenz

    if(Tree-&gt;IsDiskInDrive(dir,slVolumeName,dwVolumeSerial)){

    filehandle = FindFirstFile((dir+&quot;\\*.*&quot; ).c_str(), &amp;filedata);
    bool found = (filehandle != INVALID_HANDLE_VALUE);
    while (found == true)
    {
        String file=filedata.cFileName;
        if (((filedata.dwFileAttributes &amp; FILE_ATTRIBUTE_HIDDEN) == 0)
            &amp;&amp; (file != &quot;.&quot;) &amp;&amp; (file != &quot;..&quot;)){

           TListItem *Subfolder = Form5-&gt;ListView1-&gt;Items-&gt;Add();
           //Dateiname
           Subfolder-&gt;Caption=file;
           //Icon
           String lol=dir+&quot;\\&quot;+file;
           lol=ReplaceStr(lol,&quot;\\\\&quot;,&quot;\\&quot;);
           MyIcon-&gt;Handle=ExtractAssociatedIcon(Form5-&gt;Handle,lol.c_str(),&amp;nummer);
           if(MyIcon-&gt;Handle!=NULL)
           {
               Form5-&gt;LargeIcons-&gt;AddIcon(MyIcon);
               Form5-&gt;ListIcons-&gt;AddIcon(MyIcon);

           }
           Subfolder-&gt;ImageIndex=i;
           i++;

           //FileTime
           FileTimeToSystemTime(&amp;filedata.ftLastWriteTime,&amp;stcUTC);
           SystemTimeToTzSpecificLocalTime(NULL, &amp;stcUTC, &amp;stLocal);
           if(stLocal.wMinute&lt;10){
              minute=&quot;0&quot;+IntToStr(stLocal.wMinute);
           }else{
              minute=IntToStr(stLocal.wMinute);
           }
           if(stLocal.wHour&lt;10){
              hour=&quot;0&quot;+IntToStr(stLocal.wHour);
           }else{
              hour=IntToStr(stLocal.wHour);
           }
           date=IntToStr(stLocal.wDay)+&quot;.&quot;+IntToStr(stLocal.wMonth)+&quot;.&quot;+IntToStr(stLocal.wYear)+&quot; &quot;+hour+&quot;:&quot;+minute;
           Subfolder-&gt;SubItems-&gt;Add(date);

           if((filedata.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY) ==0){

               //Typ
               pos=LastDelimiter(&quot;.&quot;,filedata.cFileName);
               typ=String(filedata.cFileName);
               typ=typ.Delete(1,pos);
               if(typ==&quot;Ink&quot;){
                   Subfolder-&gt;SubItems-&gt;Add(&quot;Verknüpfung&quot;);
               }else{
                   Subfolder-&gt;SubItems-&gt;Add(typ+&quot;-Datei&quot;);
               }
               //Größe hierher
               size=filedata.nFileSizeLow;
               SetRoundMode(rmDown);
               if(size&lt;1024){
                   groesse=FloatToStr(size)+&quot; Bytes&quot;;
               }else if(size&gt;=1024 &amp;&amp; size&lt;1048576){
                   size=RoundTo(size/1024,-2);
                   groesse=FloatToStrF(size,ffGeneral,4,DecimalSeparator)+&quot; KB&quot;;
               }else if(size&gt;=1048576 &amp;&amp; size&lt;1073741824){
                   size=RoundTo(size/1024/1024,-2);
                   groesse=FloatToStrF(size,ffGeneral,4,DecimalSeparator)+&quot; MB&quot;;
               }else if(size&gt;=1073741824){ // stimmt das??
                   size=filedata.nFileSizeHigh*4+size/1024/1024/1024;
                   groesse=FloatToStrF(size,ffGeneral,4,DecimalSeparator)+&quot; GB&quot;;
               }else{
                   groesse=&quot;[Dateigröße konnte nicht bestimmt werden]&quot;;
               }

               Subfolder-&gt;SubItems-&gt;Add(groesse);
           }else{
               Subfolder-&gt;SubItems-&gt;Add(&quot;Verzeichnis&quot;);
               Subfolder-&gt;SubItems-&gt;Add(&quot;[-]&quot;);
           }
        }
        else
        {
        }
        found = FindNextFile(filehandle, &amp;filedata);

    }
    if(Form5-&gt;ListView1-&gt;Items-&gt;Count!=0){
    Form5-&gt;ListView1-&gt;Items-&gt;operator [](0)-&gt;Selected=true;
    Form5-&gt;ListView1-&gt;Focused();
    }
    FindClose(filehandle);
    DestroyIcon(MyIcon);
    }
</code></pre>
<p>Grüße XBert</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196433/optimieren-von-funktion</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 12:16:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196433.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Oct 2007 17:07:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Optimieren von Funktion on Mon, 29 Oct 2007 17:07:37 GMT]]></title><description><![CDATA[<p>Hi Leute ich bin mir zwar nicht ganz sicher ob es das richtige Forum ist,<br />
aber ich schildere hier mal mein Problem:<br />
Ich habe eine Funktion geschrieben die mir den Inhal eines Verzeichnis ausgibt.<br />
Es ist in einem eigenen Thread arbeitet mir aber zu langsam! Wie kann ich das ändern (optimieren)?</p>
<pre><code class="language-cpp">Form5-&gt;ListView1-&gt;Items-&gt;Clear();
    WIN32_FIND_DATA filedata;
    AnsiString slVolumeName;
    DWORD dwVolumeSerial;
    HANDLE filehandle;
    SYSTEMTIME stcUTC,stLocal;
    DWORDLONG filesize;
    int pos,i=0;
    float size;
    String groesse,date,minute,hour,typ,dir=pfad;
    WORD nummer;
    TIcon *MyIcon = new TIcon();

    Form5-&gt;ListIcons-&gt;Clear();
    Form5-&gt;ListIcons-&gt;BkColor= (TColor)0x00FFFFFF;    //Transparenz
    Form5-&gt;LargeIcons-&gt;Clear();
    Form5-&gt;LargeIcons-&gt;BkColor= (TColor)0x00FFFFFF;    //Transparenz

    if(Tree-&gt;IsDiskInDrive(dir,slVolumeName,dwVolumeSerial)){

    filehandle = FindFirstFile((dir+&quot;\\*.*&quot; ).c_str(), &amp;filedata);
    bool found = (filehandle != INVALID_HANDLE_VALUE);
    while (found == true)
    {
        String file=filedata.cFileName;
        if (((filedata.dwFileAttributes &amp; FILE_ATTRIBUTE_HIDDEN) == 0)
            &amp;&amp; (file != &quot;.&quot;) &amp;&amp; (file != &quot;..&quot;)){

           TListItem *Subfolder = Form5-&gt;ListView1-&gt;Items-&gt;Add();
           //Dateiname
           Subfolder-&gt;Caption=file;
           //Icon
           String lol=dir+&quot;\\&quot;+file;
           lol=ReplaceStr(lol,&quot;\\\\&quot;,&quot;\\&quot;);
           MyIcon-&gt;Handle=ExtractAssociatedIcon(Form5-&gt;Handle,lol.c_str(),&amp;nummer);
           if(MyIcon-&gt;Handle!=NULL)
           {
               Form5-&gt;LargeIcons-&gt;AddIcon(MyIcon);
               Form5-&gt;ListIcons-&gt;AddIcon(MyIcon);

           }
           Subfolder-&gt;ImageIndex=i;
           i++;

           //FileTime
           FileTimeToSystemTime(&amp;filedata.ftLastWriteTime,&amp;stcUTC);
           SystemTimeToTzSpecificLocalTime(NULL, &amp;stcUTC, &amp;stLocal);
           if(stLocal.wMinute&lt;10){
              minute=&quot;0&quot;+IntToStr(stLocal.wMinute);
           }else{
              minute=IntToStr(stLocal.wMinute);
           }
           if(stLocal.wHour&lt;10){
              hour=&quot;0&quot;+IntToStr(stLocal.wHour);
           }else{
              hour=IntToStr(stLocal.wHour);
           }
           date=IntToStr(stLocal.wDay)+&quot;.&quot;+IntToStr(stLocal.wMonth)+&quot;.&quot;+IntToStr(stLocal.wYear)+&quot; &quot;+hour+&quot;:&quot;+minute;
           Subfolder-&gt;SubItems-&gt;Add(date);

           if((filedata.dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY) ==0){

               //Typ
               pos=LastDelimiter(&quot;.&quot;,filedata.cFileName);
               typ=String(filedata.cFileName);
               typ=typ.Delete(1,pos);
               if(typ==&quot;Ink&quot;){
                   Subfolder-&gt;SubItems-&gt;Add(&quot;Verknüpfung&quot;);
               }else{
                   Subfolder-&gt;SubItems-&gt;Add(typ+&quot;-Datei&quot;);
               }
               //Größe hierher
               size=filedata.nFileSizeLow;
               SetRoundMode(rmDown);
               if(size&lt;1024){
                   groesse=FloatToStr(size)+&quot; Bytes&quot;;
               }else if(size&gt;=1024 &amp;&amp; size&lt;1048576){
                   size=RoundTo(size/1024,-2);
                   groesse=FloatToStrF(size,ffGeneral,4,DecimalSeparator)+&quot; KB&quot;;
               }else if(size&gt;=1048576 &amp;&amp; size&lt;1073741824){
                   size=RoundTo(size/1024/1024,-2);
                   groesse=FloatToStrF(size,ffGeneral,4,DecimalSeparator)+&quot; MB&quot;;
               }else if(size&gt;=1073741824){ // stimmt das??
                   size=filedata.nFileSizeHigh*4+size/1024/1024/1024;
                   groesse=FloatToStrF(size,ffGeneral,4,DecimalSeparator)+&quot; GB&quot;;
               }else{
                   groesse=&quot;[Dateigröße konnte nicht bestimmt werden]&quot;;
               }

               Subfolder-&gt;SubItems-&gt;Add(groesse);
           }else{
               Subfolder-&gt;SubItems-&gt;Add(&quot;Verzeichnis&quot;);
               Subfolder-&gt;SubItems-&gt;Add(&quot;[-]&quot;);
           }
        }
        else
        {
        }
        found = FindNextFile(filehandle, &amp;filedata);

    }
    if(Form5-&gt;ListView1-&gt;Items-&gt;Count!=0){
    Form5-&gt;ListView1-&gt;Items-&gt;operator [](0)-&gt;Selected=true;
    Form5-&gt;ListView1-&gt;Focused();
    }
    FindClose(filehandle);
    DestroyIcon(MyIcon);
    }
</code></pre>
<p>Grüße XBert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394251</guid><dc:creator><![CDATA[XBert]]></dc:creator><pubDate>Mon, 29 Oct 2007 17:07:37 GMT</pubDate></item><item><title><![CDATA[Reply to Optimieren von Funktion on Mon, 29 Oct 2007 17:50:37 GMT]]></title><description><![CDATA[<p>XBert schrieb:</p>
<blockquote>
<p>Wie kann ich das ändern (optimieren)?</p>
</blockquote>
<p>Anfangen kannst du, indem du einzelne Abschnitte auskommentierst und mittels wiederholter Durchläufe prüfst, bei welcher Aktion die meiste Zeit draufgeht.<br />
Ausserdem solltest du mal einen Blick auf das VirtualListView-Projekt im examples-Verzeichnis werfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394277</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Mon, 29 Oct 2007 17:50:37 GMT</pubDate></item><item><title><![CDATA[Reply to Optimieren von Funktion on Mon, 29 Oct 2007 17:54:40 GMT]]></title><description><![CDATA[<p>ich weiß ja was am längsten braucht : die Icons holen<br />
Ich will ja das mit den Icons optimieren denn wenn ich zu bsp den System32-ordner auslese dauert das zwischen 20 u 30 sekunden (und das ist viel zu lang)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394281</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394281</guid><dc:creator><![CDATA[XBert]]></dc:creator><pubDate>Mon, 29 Oct 2007 17:54:40 GMT</pubDate></item><item><title><![CDATA[Reply to Optimieren von Funktion on Mon, 29 Oct 2007 17:57:11 GMT]]></title><description><![CDATA[<p>Du fügst bei bei allen Dateien das Icon in die Imagelist, dass lässt sich Optimieren indem du vorab die Icons in die ImageList lädst.</p>
<p>ala</p>
<pre><code class="language-cpp">//Einlesen der Systemicons in das ImageListFileSymbols
	SHFILEINFO SHFileInfo;

	//kleine Symbole
	DWORD ImageHandle = SHGetFileInfo(&quot;&quot;, 0, &amp;SHFileInfo, sizeof(SHFileInfo), SHGFI_SMALLICON|SHGFI_SHELLICONSIZE|SHGFI_SYSICONINDEX);
	if (ImageHandle != 0)
	{
		m_ImageList-&gt;Handle = ImageHandle;
		m_ImageList-&gt;ShareImages = true;
	}

	//grosse Symbole
	DWORD ImageHandle32 = SHGetFileInfo(&quot;&quot;, 0, &amp;SHFileInfo, sizeof(SHFileInfo), SHGFI_ICON|SHGFI_SHELLICONSIZE|SHGFI_SYSICONINDEX);
	if (ImageHandle32 != 0)
	{
		m_ImageList32-&gt;Handle = ImageHandle32;
		m_ImageList32-&gt;ShareImages = true;
	}
</code></pre>
<p>und dann drauf verweisst mittels</p>
<pre><code class="language-cpp">AnsiString File = item.Path + &quot;\\&quot; + sr.Name;
				DWORD result = SHGetFileInfo(File.c_str(),
											0,
											&amp;info,
											sizeof(info),
											SHGFI_ICON |
											SHGFI_SMALLICON);
				if (result != 0) Subfolder-&gt;ImageIndex= info.iIcon;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1394285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394285</guid><dc:creator><![CDATA[VergissEs]]></dc:creator><pubDate>Mon, 29 Oct 2007 17:57:11 GMT</pubDate></item><item><title><![CDATA[Reply to Optimieren von Funktion on Tue, 30 Oct 2007 12:41:37 GMT]]></title><description><![CDATA[<p>Danke das funktionier eigentlich ganz gut außer das bei manchen Ordnern keine Icons angezeigt werden.<br />
(Kann ich die Sys-Icons beim FormCreate kopieren oder in der Funktion)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394652</guid><dc:creator><![CDATA[XBert]]></dc:creator><pubDate>Tue, 30 Oct 2007 12:41:37 GMT</pubDate></item></channel></rss>