<?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[strsafe.h unter dem BCB?]]></title><description><![CDATA[<p>Hallo,</p>
<p>Kurze und knappe Frage.<br />
Ich will folgenden Beispiel Code aus der MSDN kompilieren:</p>
<pre><code>#define _WIN32_WINNT 0x0501

#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;strsafe.h&gt;
#include &lt;malloc.h&gt;

#define BUFSIZE MAX_PATH

int main(int argc, char *argv[])
{
   WIN32_FIND_DATA FindFileData;
   HANDLE hFind = INVALID_HANDLE_VALUE;
   DWORD dwError;
   LPSTR DirSpec;
   size_t length_of_arg;

   DirSpec = (LPSTR) malloc (BUFSIZE);

   // Check for command-line parameter; otherwise, print usage.
   if(argc != 2)
   {
      printf(&quot;Usage: Test &lt;dir&gt;\n&quot;);
      return 2;
   }

   // Check that the input is not larger than allowed.
   StringCbLength(argv[1], BUFSIZE, &amp;length_of_arg);
   if (length_of_arg &gt; (BUFSIZE - 2))
   {
      printf(&quot;Input directory is too large.\n&quot;);
      return 3;
   }

   printf (&quot;Target directory is %s.\n&quot;, argv[1]);

   // Prepare string for use with FindFile functions.  First, 
   // copy the string to a buffer, then append '\*' to the 
   // directory name.
   StringCbCopyN (DirSpec, BUFSIZE, argv[1], length_of_arg+1);
   StringCbCatN (DirSpec, BUFSIZE, &quot;\\*&quot;, 3);

   // Find the first file in the directory.
   hFind = FindFirstFile(DirSpec, &amp;FindFileData);

   if (hFind == INVALID_HANDLE_VALUE) 
   {
      printf (&quot;Invalid file handle. Error is %u.\n&quot;, GetLastError());
      return (-1);
   } 
   else 
   {
      printf (&quot;First file name is %s.\n&quot;, FindFileData.cFileName);

						// List all the other files in the directory.
      while (FindNextFile(hFind, &amp;FindFileData) != 0) 
      {
         printf (&quot;Next file name is %s.\n&quot;, FindFileData.cFileName);
      }

      dwError = GetLastError();
      FindClose(hFind);
      if (dwError != ERROR_NO_MORE_FILES) 
      {
         printf (&quot;FindNextFile error. Error is %u.\n&quot;, dwError);
         return (-1);
      }
   }

   free(DirSpec);
   return (0);
}
</code></pre>
<p>Dabei erhalte ich folgende Fehlermeldungen:</p>
<pre><code>[C++ Fehler] Unit1.cpp(5): E2209 include-Datei 'strsafe.h' kann nicht geöffnet werden
[C++ Fehler] Unit1.cpp(29): E2268 Aufruf der undefinierten Funktion 'StringCbLength'
[C++ Fehler] Unit1.cpp(41): E2268 Aufruf der undefinierten Funktion 'StringCbCopyN'
[C++ Fehler] Unit1.cpp(42): E2268 Aufruf der undefinierten Funktion 'StringCbCatN'
</code></pre>
<p>Den Header strsafe gibt's wohl nicht.<br />
Wie mache ich es denn richtig, dass es unter dem Borland C++ Builder 6 läuft?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/155138/strsafe-h-unter-dem-bcb</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 17:37:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/155138.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Aug 2006 02:04:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to strsafe.h unter dem BCB? on Thu, 03 Aug 2006 02:04:11 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Kurze und knappe Frage.<br />
Ich will folgenden Beispiel Code aus der MSDN kompilieren:</p>
<pre><code>#define _WIN32_WINNT 0x0501

#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;strsafe.h&gt;
#include &lt;malloc.h&gt;

#define BUFSIZE MAX_PATH

int main(int argc, char *argv[])
{
   WIN32_FIND_DATA FindFileData;
   HANDLE hFind = INVALID_HANDLE_VALUE;
   DWORD dwError;
   LPSTR DirSpec;
   size_t length_of_arg;

   DirSpec = (LPSTR) malloc (BUFSIZE);

   // Check for command-line parameter; otherwise, print usage.
   if(argc != 2)
   {
      printf(&quot;Usage: Test &lt;dir&gt;\n&quot;);
      return 2;
   }

   // Check that the input is not larger than allowed.
   StringCbLength(argv[1], BUFSIZE, &amp;length_of_arg);
   if (length_of_arg &gt; (BUFSIZE - 2))
   {
      printf(&quot;Input directory is too large.\n&quot;);
      return 3;
   }

   printf (&quot;Target directory is %s.\n&quot;, argv[1]);

   // Prepare string for use with FindFile functions.  First, 
   // copy the string to a buffer, then append '\*' to the 
   // directory name.
   StringCbCopyN (DirSpec, BUFSIZE, argv[1], length_of_arg+1);
   StringCbCatN (DirSpec, BUFSIZE, &quot;\\*&quot;, 3);

   // Find the first file in the directory.
   hFind = FindFirstFile(DirSpec, &amp;FindFileData);

   if (hFind == INVALID_HANDLE_VALUE) 
   {
      printf (&quot;Invalid file handle. Error is %u.\n&quot;, GetLastError());
      return (-1);
   } 
   else 
   {
      printf (&quot;First file name is %s.\n&quot;, FindFileData.cFileName);

						// List all the other files in the directory.
      while (FindNextFile(hFind, &amp;FindFileData) != 0) 
      {
         printf (&quot;Next file name is %s.\n&quot;, FindFileData.cFileName);
      }

      dwError = GetLastError();
      FindClose(hFind);
      if (dwError != ERROR_NO_MORE_FILES) 
      {
         printf (&quot;FindNextFile error. Error is %u.\n&quot;, dwError);
         return (-1);
      }
   }

   free(DirSpec);
   return (0);
}
</code></pre>
<p>Dabei erhalte ich folgende Fehlermeldungen:</p>
<pre><code>[C++ Fehler] Unit1.cpp(5): E2209 include-Datei 'strsafe.h' kann nicht geöffnet werden
[C++ Fehler] Unit1.cpp(29): E2268 Aufruf der undefinierten Funktion 'StringCbLength'
[C++ Fehler] Unit1.cpp(41): E2268 Aufruf der undefinierten Funktion 'StringCbCopyN'
[C++ Fehler] Unit1.cpp(42): E2268 Aufruf der undefinierten Funktion 'StringCbCatN'
</code></pre>
<p>Den Header strsafe gibt's wohl nicht.<br />
Wie mache ich es denn richtig, dass es unter dem Borland C++ Builder 6 läuft?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1109600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1109600</guid><dc:creator><![CDATA[strsafe.h]]></dc:creator><pubDate>Thu, 03 Aug 2006 02:04:11 GMT</pubDate></item><item><title><![CDATA[Reply to strsafe.h unter dem BCB? on Thu, 03 Aug 2006 08:17:49 GMT]]></title><description><![CDATA[<p>Verwende C++ statt C. Dann gibt es keine Probleme.<br />
Was ich damit meine, ist, ersetze diese StringCB.. Funktionen und char* durch string oder AnsiString , FindFirstFile und FindNextFile durch FindFirst und FindNext (wenn du VCL verwenden willst).<br />
Etwa so (ohne VCL)</p>
<pre><code class="language-cpp">//#define _WIN32_WINNT 0x0501

#include &lt;windows.h&gt;
//#include &lt;cstdio&gt;
#include &lt;iostream&gt;
using namspace std;

//#define BUFSIZE MAX_PATH

int main(int argc, char *argv[])
{
   // Check for command-line parameter; otherwise, print usage.
   if(argc != 2)
   {
      cout &lt;&lt; &quot;Usage: Test &lt;dir&gt;\n&quot;;
      return 2;
   }

   WIN32_FIND_DATA FindFileData;

   cout &lt;&lt; &quot;Target directory is &quot; &lt;&lt; argv[1] &lt;&lt; &quot;\n&quot;;

   // Prepare string for use with FindFile functions.  First,
   // copy the string to a buffer, then append '\*' to the
   // directory name.
   string DirSpec(argv[1]);
   DirSpec += &quot;\\*&quot;;

   // Find the first file in the directory.
   HANDLE hFind = FindFirstFile(DirSpec.c_str(), &amp;FindFileData);

   if (hFind == INVALID_HANDLE_VALUE)
   {
      cout &lt;&lt; &quot;Invalid file handle. Error is&quot; &lt;&lt;  GetLastError() &lt;&lt; &quot;\n&quot;;
      return -1;
   }
   else
   {
      cout &lt;&lt; &quot;First file name is &quot; &lt;&lt;  FindFileData.cFileName &lt;&lt; &quot;.\n&quot;;

                        // List all the other files in the directory.
      while (FindNextFile(hFind, &amp;FindFileData) != 0)
      {
         cout &lt;&lt; &quot;Next file name is &quot; &lt;&lt; FindFileData.cFileName &lt;&lt; &quot;.\n&quot;;
      }

      DWORD dwError = GetLastError();
      FindClose(hFind);
      if (dwError != ERROR_NO_MORE_FILES)
      {
         cout &lt;&lt; &quot;FindNextFile error. Error is &quot; &lt;&lt; dwError &lt;&lt; &quot;.\n&quot;;
         return (-1);
      }
   }
   return (0);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1109677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1109677</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 03 Aug 2006 08:17:49 GMT</pubDate></item><item><title><![CDATA[Reply to strsafe.h unter dem BCB? on Thu, 03 Aug 2006 13:38:51 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1387">@Braunstein</a>: Danke schonmal!</p>
<p>Kannst du mir jetzt noch sagen, wie ich es anwende?<br />
Bei mir geht es irgendwie nicht...</p>
<p>Ich rufe die Konsole auf,<br />
geh in das Verzeichnis wo meine Programm.exe liegt und gebe</p>
<pre><code>programm.exe Test C:\Programme
</code></pre>
<p>ein.</p>
<p>Steht ja hier:</p>
<pre><code>cout &lt;&lt; &quot;Usage: Test &lt;dir&gt;\n&quot;;
</code></pre>
<p>Aber dann kommt wieder die Usage Meldung...<br />
Was mache ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1109942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1109942</guid><dc:creator><![CDATA[strsafe.h]]></dc:creator><pubDate>Thu, 03 Aug 2006 13:38:51 GMT</pubDate></item><item><title><![CDATA[Reply to strsafe.h unter dem BCB? on Thu, 03 Aug 2006 13:45:32 GMT]]></title><description><![CDATA[<p>Das Test, was da steht soll der Programmname sein. Bei dir dann eben programm.exe.<br />
Du mußt also folgendes eintippen</p>
<blockquote>
<p>programm.exe C:\Programme</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1109953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1109953</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 03 Aug 2006 13:45:32 GMT</pubDate></item></channel></rss>