#### Archived

This topic is now archived and is closed to further replies.

# Who's heared of SyncObjs?

This topic is 5890 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

This is really getting me pissed now. Not too long ago, I wanted to use DirectInput buffering with the mouse. Easy, since I could copy someone else's code. But I couldn't. Why? Because I didn't have a dumb unit called "SyncObjs". I wouldn't have minded this, but after downloading some DX8 components yesterday I realised that some of them needed it too, I reeeaaaalllly want to get it. So if anyone knows where I can get my clammy hands on this unit, or if someone has it, please tell me where I can get it, or EMail it to me. Thanks. ~ There's no substitute for failure ~ Edited by - MarkyD on October 24, 2001 4:20:39 AM

#### Share this post

##### Share on other sites
There was another post here about that unit a little while back. I found it in my D6 Personal installation. I don''t have D5 here to check if it is present in there. The SyncObjs unit declares a TCriticalSection object. This can be easily replaced by the TRTLCriticalSection record and the Win32 API functions that go with it.

Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios

#### Share this post

##### Share on other sites
quote:

There was another post here about that unit a little while back

I know about the other thread - I was the one who posted that.

It''s just because seeing a lot of my units want to use SyncObjs, it might be better just to have it rather then alter every unit that uses it. I doesn''t seem logical to go through every unit changing TCriticalSection to TRTLCriticalSection, especially the DX ones.

Also, I tried my code again changing this over and the compiler didn''t like...

procedure EnterCrit;var  CritSec: TRTLCriticalSection;begin     CritSec.Enter; // "Enter" isn''t recognised by the compilerend;

I think it was with ".enter", but it may be something else. I''ll try it again and check, but I hope you can see how annoying it can be messing all about with this when all I need is the unit itself - and I''ll be laughing away.

quote:

I found it

My EMail''s MarkyD@GDNMail.net, btw. Hint.

~ There''s no substitute for failure ~

#### Share this post

##### Share on other sites
TRTLCriticalSection is not a class, but a record. Therefore it does not contain any methods. You use the record with the standard Win32 critical section functions.

What are the units that you downloaded that contain SyncObjs? It seems the author is using Delphi 6 and does not realise that SyncObjs is not included with Delphi 5 and lower. But if all they are using is TCriticalSection, then you can easily roll your own class.
unit SyncObjs;interfaceuses  Windows;type  TCriticalSection = class  private    FCriticalSection: TRTLCriticalSection;  public    constructor Create;    destructor Destroy; override;    procedure Enter;    procedure Leave;    function TryEnter: Boolean;  end;implementationconstructor TCriticalSection.Create;begin  InitializeCriticalSection(FCriticalSection);end;destructor TCriticalSection.Destroy;begin  DeleteCriticalSection(FCriticalSection);  inherited;end;procedure TCriticalSection.Enter;begin  EnterCriticalSection(FCriticalSection);end;procedure TCriticalSection.Leave;begin  LeaveCriticalSection(FCriticalSection);end;function TCriticalSection.TryEnter: Boolean;begin  Result := TryEnterCriticalSection(FCriticalSection);end;end.
Give that a try. I do not know if that is exactly how Delphi 6's SyncObjs unit declares TCriticalSection because all I have is D6 Personal and it contains no information on this class or unit, but it does have the DCU.

Steve 'Sly' Williams   Monkey Wrangler  Krome Studios

Edited by - sly on October 25, 2001 7:20:52 PM

#### Share this post

##### Share on other sites
YYYYYYYYYYYYYEEEEEEEEEEEEEEEEESSSSSSSSSSSSSSSSSSSSSSSS!!!!

Righto. Now that I''ve got that out of my system I can very happily tell you that that worked! THANK YOU!!!

~ There''s no substitute for failure ~

• ### Forum Statistics

• Total Topics
628636
• Total Posts
2983966

• 10
• 18
• 20
• 13
• 9