About Terminal Server, Citrix, Delphi and other stuff
A few days ago I wrote about Using Windows Dialogs in your own programs, wouldn’t it be nice to be able to use Windows Resource Strings for the same reasons?
Loading a resource string is not difficult, let’s look at some examples:
if LoadString(hDll, ResourceId, Buffer, Length(Buffer)) > 0 then
Result := Buffer;
end;
This uses the LoadString api to load a Resource String from an Executable or Dll by it’s resource Id. An Example might call might be:
This loads the string with ResourceId 226 from dsadmin.dll(.mui):
As you can see in this example, some resource strings have identifiers such as %1 and %2 which are used in the FormatMessage Api. How can we use that from Delphi?
I wrote a very simple wrapper for it:
if FormatMessage(FORMAT_MESSAGE_FROM_STRING or
FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_ARGUMENT_ARRAY,
PChar(Source), 0, 0, @Buffer, 0, @ArgArray[0]) > 0 then
begin
Result := Buffer;
// replace \n (linefeed) with #13#10
Result := StringReplace(Result, ‘\n’, #13#10, [rfReplaceAll]);
LocalFree(DWORD(Buffer));
end
else begin
SetLength(Result, 0);
end;
end;
And here is a usage example:
The Result of this is:
Windows cannot complete the password change for John Doe because:
the password doesn’t meet complexity requirements
Related posts:
Active Directory Altiris bug Citrix Dell Delphi Exchange Exchange2003 Exchange2010 Hewlett-Packard HP iOS Jailbreak Java LinkedIn Linux MSI MySQL Navigation Objects Office Outlook Passat PowerPoint PowerShell referall was returned RNS315 RNS510 SasLibEx script slow Terminal Server ThinApp TSAdmin TSAdminEx VBS VCDS Vista VMWare Volkswagen Windows PE WLAN Wordpress WTSWaitSystemEvent wts_event_flush
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.
Leave a reply