15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


HELP: How to limit number of instances in OCX

Junanto -- jnt@cbn.net.id
Tuesday, December 24, 1996


Environment: VC 4.0, Win95

I'd like to limit the number of my control's instances that users can
insert into their application. For example, in a single system a maximum
number of 4 instances of my control can be created. The subsequent
instantiation will fail.

I have tried to override COleObjectFactory::VerifyLicenseKey() which is
supposed to be called before each instance creation. In this function, I
simply checked the number of instances already created and return FALSE
when the limit is reached.

It doesn't work as expected since users can still create as many instances
as they like.

Any help will be greatly appreciated.

- Junanto (jnt@cbn.net.id)





Scot -- Scot@STINGSOFT.COM
Thursday, December 26, 1996

The MFC FAQ http://www.stingsoft.com/mfc_faq
has a solution to this.  I think it uses semaphores.

Scot

>----------
>From: 	Junanto[SMTP:]
>Sent: 	Tuesday, December 24, 1996 2:10 AM
>To: 	mfc-l@netcom.com
>Subject: 	HELP: How to limit number of instances in OCX
>Importance: 	High
>
>
>Environment: VC 4.0, Win95
>
>I'd like to limit the number of my control's instances that users can
>insert into their application. For example, in a single system a maximum
>number of 4 instances of my control can be created. The subsequent
>instantiation will fail.
>
>I have tried to override COleObjectFactory::VerifyLicenseKey() which is
>supposed to be called before each instance creation. In this function, I
>simply checked the number of instances already created and return FALSE
>when the limit is reached.
>
>It doesn't work as expected since users can still create as many instances
>as they like.
>
>Any help will be greatly appreciated.
>
>- Junanto (jnt@cbn.net.id)
>
>
>




| Вернуться в корень Архива |