mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 01:19:38 +01:00 
			
		
		
		
	* fixed stream resource unicode issue
git-svn-id: trunk@1160 -
This commit is contained in:
		
							parent
							
								
									2476957db9
								
							
						
					
					
						commit
						84cd7d6706
					
				@ -755,30 +755,52 @@ end;
 | 
			
		||||
{*                             TResourceStream                              *}
 | 
			
		||||
{****************************************************************************}
 | 
			
		||||
 | 
			
		||||
procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PChar);
 | 
			
		||||
{$ifdef UNICODE}
 | 
			
		||||
procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PWideChar);
 | 
			
		||||
  begin
 | 
			
		||||
    Res:=FindResource(Instance, Name, ResType);
 | 
			
		||||
    if Res=0 then 
 | 
			
		||||
    if Res=0 then
 | 
			
		||||
      raise EResNotFound.CreateFmt(SResNotFound,[Name]);
 | 
			
		||||
    Handle:=LoadResource(Instance,Res);
 | 
			
		||||
    if Handle=0 then
 | 
			
		||||
      raise EResNotFound.CreateFmt(SResNotFound,[Name]);
 | 
			
		||||
    SetPointer(LockResource(Handle),SizeOfResource(Instance,Res));    
 | 
			
		||||
    SetPointer(LockResource(Handle),SizeOfResource(Instance,Res));
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
constructor TResourceStream.Create(Instance: THandle; const ResName: WideString; ResType: PWideChar);
 | 
			
		||||
  begin
 | 
			
		||||
    inherited create;
 | 
			
		||||
    Initialize(Instance,PWideChar(ResName),ResType);
 | 
			
		||||
  end;
 | 
			
		||||
constructor TResourceStream.CreateFromID(Instance: THandle; ResID: Integer; ResType: PWideChar);
 | 
			
		||||
  begin
 | 
			
		||||
    inherited create;
 | 
			
		||||
    Initialize(Instance,PWideChar(ResID),ResType);
 | 
			
		||||
  end;
 | 
			
		||||
{$else UNICODE}
 | 
			
		||||
 | 
			
		||||
procedure TResourceStream.Initialize(Instance: THandle; Name, ResType: PChar);
 | 
			
		||||
  begin
 | 
			
		||||
    Res:=FindResource(Instance, Name, ResType);
 | 
			
		||||
    if Res=0 then
 | 
			
		||||
      raise EResNotFound.CreateFmt(SResNotFound,[Name]);
 | 
			
		||||
    Handle:=LoadResource(Instance,Res);
 | 
			
		||||
    if Handle=0 then
 | 
			
		||||
      raise EResNotFound.CreateFmt(SResNotFound,[Name]);
 | 
			
		||||
    SetPointer(LockResource(Handle),SizeOfResource(Instance,Res));
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
constructor TResourceStream.Create(Instance: THandle; const ResName: string; ResType: PChar);
 | 
			
		||||
  begin
 | 
			
		||||
    inherited create;
 | 
			
		||||
    Initialize(Instance,pchar(ResName),ResType);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
constructor TResourceStream.CreateFromID(Instance: THandle; ResID: Integer; ResType: PChar);
 | 
			
		||||
  begin
 | 
			
		||||
    inherited create;
 | 
			
		||||
    Initialize(Instance,pchar(PtrInt(ResID)),ResType);
 | 
			
		||||
  end;
 | 
			
		||||
{$endif UNICODE}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
destructor TResourceStream.Destroy;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user