amjadtbssm / DirectShowDelphi

MS Direct Show Package for Delphi
0 stars 1 forks source link

GetErrorString produces garbage when faces an unknown error code #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use GetErrorString to have detailed error message
2. Send some unknown parameter to the function
3. result will be some boxes and garbage characters

What is the expected output? What do you see instead?
The output should be the error message, or, when there is no predefined 
message, return "unknown error" instead of garbage.

What version of the product are you using? On what operating system?
I am using WinXP, Delphi XE2

Please provide any additional information below.
Function could be like this:
  function GetErrorString(hr: HRESULT): String;
  var
    buffer: array[0..254] of Char;
    Res: Cardinal;
  begin
    Res := AMGetErrorText(hr, @buffer[0], 255);
    if Res = 0 Then
    Begin
      Result := 'Unknown error'
    End
    Else
      result := buffer;
  end;

Note that there is error checking.
unit DXSUtil;
     *  DSPack 2.3.3                                                     *

Original issue reported on code.google.com by celaler...@gmail.com on 28 Feb 2012 at 11:56