- Details
- Written by: Stanko Milosev
- Category: Delphi
- Hits: 5015
If you want to change regional settings for your application (not globaly for Windows), you can use this code:
function MakeLCID( lgID: Word; srtid: Word ): DWORD;
begin
Result := MakeLong( lgid, srtid );
end;
function MakeLangID( p, s: Word ): Word;
begin
Result := (s shl 10) or p
end;
procedure TForm3.btn1Click(Sender: TObject);
begin
Win32Check( SetThreadLocale(
MakeLCID(
MakeLangID( LANG_ENGLISH, SUBLANG_ENGLISH_US), 0)));
GetFormatSettings;
Application.UpdateFormatSettings := false;
ShowMessage(FormatDateTime('ddd, dd mmm yyyy hh:nn:ss +0200', Now));
end;
Taken from here.
- Details
- Written by: Stanko Milosev
- Category: Delphi
- Hits: 4758
If CreateProcess doesn't work:
if CreateProcess ... then ... else //it doesn't work strLog := SysErrorMessage(GetLastError ); //information why it doesn't work
- Details
- Written by: Stanko Milosev
- Category: Delphi
- Hits: 5148
To create RSS XML file, with OmniXML, you can use following code:
uses rrRss, OmniXML, SysUtils, Windows, OmniXMLProperties;
...
var
rss: TRSS;
...
rss := TRSS.Create;
rss.XMLDoc.PreserveWhiteSpace := False; //for XML to be "human readable"
rss.Version := '2.0'; //RSS version
//adding channel
rss.Add;
rss.Channel[0].Title := 'channel name';
rss.Channel[0].Link := 'link';
rss.Channel[0].Description := 'description';
...
//adding RSS feed
rss.Channel[0].Items.Add;
//it depends of RSS reader will consider this property
rss.Channel[0].Items[0].Guid.Value := 'guid';
rss.Channel[0].Items[0].Title := 'title';
//link where will be full article
rss.Channel[0].Items[0].Link := 'http://www.rsslink.com';
//content of RSS which will be shown in RSS reader
rss.Channel[0].Items[0].Description := 'description';
rss.Channel[0].Items[0].Category := 'test';
//date of publish
rss.Channel[0].Items[0].PubDate := 'ned, 05 jul 2009 17:00:23 +0200';
//because of FireFox, without this in FF don't want to work
rss.Channel[0].Items[intItemCount].Enclosure.Url := 'http://www.milosev.com';
//ofIndent also needed for XML to be "human readable"
if not rss.SaveToFile(strFileName, ofIndent) then
raise Exception.Create(rss.LastError);
RSS specification can be found here. pubDate must follow RFC822 specification.
Code taken from OmniXML\demo\properties.
If you need in RSS description to put line break, or something similiar, try CDATA, for example:
<description><![CDATA[ <p>There once was a man from nantucket<br> Who kept all his fish in a bucket</p> ]]></description>
If link is same in RSS then it is possible that some RSS readers will show RSS feed as read (not unread), because, idea of RSS is to get small part of log (news) you need, and then to go on a link to see all news.
Taken from here.