|
the class CData is public alright?. the compiler gave this error msg:
error C2582: 'operator =' function is unavailable
|
|
|
|
|
Change your variable declaration to:
CList* pDataList, pTempList;
to
CList* pDataList, *pTempList;
pTempList without asterisk declares object, not a pointer to an object.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
What i have to do is to limit the amount of users able to access an application over the network at the same time. The application i am talking about ist not a client server app. It's just something like a calculator sitting on a network cd-rom drive.
i have to find out, how many users started this application on their workstation. If the limit of users has been reached, the next user shall not be able to start it.
i have not the slightest idea how to achieve this. Could someone please give me a hint?
|
|
|
|
|
So the application is executed on separate machines, right? In this case you need some place to keep "shared application state" - number of users. You can store it in some database available to all workstations or in a file located on network server. When your app starts, it should increment the number of users. During app shutdown you should decrement this number.
The hard part begins when you realize that application can crash and leave inconsistent information in database/shared file. Possible workaround would be saving separate 'record' for each workstation running your program. This record would contain workstation ID and "last access time". The time field is updated periodically when program runs, the updating stops after crash. If application crashes, the record would remain, but another instance of the application could be able to determine - by using time field - that the record is invalid. In this case, you need common time settings on all workstations.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thank you. I was already thinking about some kind of file located on a network server. The thing with the timestamp is a good idea. Would be even better if i could use server time. I will have to figure that out.
What really troubles me is the installation of such a thing. i think the user has to be admin to install the application. And at which directory should that file be stored. It should be definitely a common directory because every workstation has to access it. Every workstation should have the writeaccess to this directory. i don't think it will be the system-directory because in most cases only admin has writeaccess to the system-directory. So how do i figure out which directory to use? I can't ask the user during installation "please tell me a common directory on the network-server where i can put the secret access control file".
So as always the details are killing me. any further help would be appriciated.
|
|
|
|
|
> I can't ask the user during installation "please tell
> me a common directory on the network-server where i can
> put the secret access control file".
The installer should read this info from some config file, editable by the network admin. Note that the location should be specified using \\server\share syntax - without network drive letters, which may be assigned differently on different workstations.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I have never done anything like that, but it should be possible to ask the server (Win NT/2000?) how many users there is that has the file opened...
I don't see any other way to do it.
I have to say that I don't know how to deny other users access, sorry...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
There was an idea posted in, I think, DDJ a few years about which suggested creating a DirectPlay session and having each client join it. You can very easily restrict the number of allowed connections (players). It should be a lot harder to crack than something like a network share reference count.
|
|
|
|
|
The only good way to do this is to write two programs - a client service that monitors execution of programs, and a server side service that kees track of open instances.
1) When the user clicks on the targetted executable, the client side service would contact the server and ask if it's okay to run the app in question.
2) The server side would return an appropriate response associated with the number of users it thinks is using the software in question
3) The client side would allow/disallow access based on the response from the server.
4) Every x number of seconds, the client side service would tell the server side service whether or not the app was still running. You can also make it so that the client side would shut dwn the app in question if for some reason it could not contact the server after x minutes (or seconds).
5) If the server doesn't get a signal from the client side in x number of secods, it could assume that the app isn't running any longer and can automatically free up one reference to the executable, thereby allowing another user to use the executable.
This mechanism could be used to control access to any number of applications through a database or the registry.
|
|
|
|
|
I have a problem with Threads !In a console
application ,I am trying to create 10 threads using
CreateThread(..). Each Thread created tries to call the
interface function which will add records to database !The
problem is I have given separate ThreadProcs for each thread
.But, what happens is some threads log more than once.So, the
loggings of some threads are lost !But, teh number of loggings
are correct !How can I rectify the problem !
The Mutexes need not do anything here .But, i can get the
correct result only
if I use Mutex at the start of each ThreadProc .It is logically
wrong !How can i rectify the problem !
Thanx in advance for the help !
Regards,
yamini
Y.Yamini Devi.
|
|
|
|
|
First of all, you should be using _beginthread() instead of CreateThread(). CreateThread() is a Win32 call and does not initialize the C Run Time library. Second, you need to mutex protect all shared resources that are not thread safe. I don't know what your "logging" refers to, but if it is not thread safe, you need to mutex protect calls to it.
Chris Hafey
|
|
|
|
|
Thank you for the help.I tried with _beginthread().I have used mutexes to make the code Thread safe .Still, I am getting the same problem.I tried terminating the Thread with _endthread() also.But the same problem persists.What can be done ?Where am I going wrong !
I have given the code I have used for each thread.
***************************************************************
HANDLE h[10];
void ThreadProc(void*);
void main()
{
h[0]=(void*)_beginthread(ThreadProc1,0,0);
//Likewise All other 9 threads are created here .
WaitForMultipleObjects(5,h,TRUE,INFINITE);
}
void ThreadProc1(void* p)
{
//code for logging into database goes here
_endthread();
}
****************************************************************
Help me to rectify the problem .
Y.Yamini Devi
|
|
|
|
|
Last time I checked, the thread will exit on its own if you leave (return from) the thread function. There is no need to call _endthread() from within the thread itself.
|
|
|
|
|
I have a problem with Threads !In a console
application ,I am trying to create 10 threads using
CreateThread(..). Each Thread created tries to call the
interface function which will add records to database !The
problem is I have given separate ThreadProcs for each thread
.But, what happens is some threads log more than once.So, the
loggings of some threads are lost !But, teh number of loggings
are correct !How can I rectify the problem !
The Mutexes need not do anything here .But, i can get the
correct result only
if I use Mutex at the start of each ThreadProc .It is logically
wrong !How can i rectify the problem !
Thanx in advance for the help !
Regards,
yamini
Y.Yamini Devi.
|
|
|
|
|
Hi folks,
I created an SDI application using AppWizard but I wish I created an MDI application. Is there any way I can convert it to MDI without re-writing my app?
Thanks for your help!
Scotland - it's nice when it's not raining.
|
|
|
|
|
I doubt it - MDI has a lot of differences to SDI, including different classes that need to be created.
Usually to make a change to what the initial options are you create two empty projects that differ only in the thing you want to chage, then run a diff tool over them. In this case, I'd say it's unlikely.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
The best way to accomplish SDI->MDI migration is creating empty MDI project and transferrind application/document/view classes from SDI to MDI. What's not moved is the CMainFrame class - it'll be different in MDI app. Additionally, you'll have to replace CSingleDocTemplate with CMultiDocTemplate in InitInstance method of your application class.
The process should be rather straightforward, and much easier than changing your existing project to MDI "in-place".
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Please help !
I've got a client and a server app running. Everything is fine. Either party will send a string to the opposite, telling the opposite when it is shutting down.
And I've got 2 problem here.
1) When I force terminate (using Task Manager)on the server app and then close the client normally , it will crash becos it doesnt know the opposite has already shut down as it tries to send string to the server, telling the server that it's going to close. How do i resolve this? Ive tried running the MSVC samples chatter and chatsvr. It crash as well.
2) How do I check out the "Connection Breakdown" when 2 app is still active? Sort of like time out handling.
Im using a CSocket derived class and has override some functions etc OnRead, OnAccept.
Any remedy?
Red Stick
|
|
|
|
|
If you use CSocketFile and CArchive classes with the CSocket class, you will get exceptions when the connection is broken or when other errors occur. So you can catch the exception before your app crashes. This is the "recommended" way to use CSocket, but nobody listens
|
|
|
|
|
Hi all,
I'm having difficulty making my wizard (based on CPropertySheet and CPropertyPage) look like the examples in Microsoft's guidelines (the Windows User Experience).
According to the book, the wizard graphic at the left should extend to the top and left edges of the wizard and also down to the horizontal line that separates the page from the Back & Next buttons. However, when using MFC's support for wizards via CPropertySheet, there is always a 7DLU border added automatically around my pages, meaning that the graphic ends up 'floating' inside the wizard window, well away from its edges. Does anyone know how I can change the automatic sizing of the wizard and positioning of its pages? I still want to use CPropertySheet, mind.
Cheers,
Mal.
|
|
|
|
|
hi,
where can i find integer identifier for control. for example IDC_RADIO1 has integer value ... ?
|
|
|
|
|
You want to know what it is ? Look in resource.h. If you want to use the value somewhere, include resource.h and use the constant.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
I start a new thread, because my previous thread was lost in the "next" "next" "next" page; nobody answer me and I still have the problem. (See my thread with the same subject of 11 May).
I read the article that Chenzhu suggest me. But my problem isn't about the accelerator keys, I have the problem with each kind of keys. It seems that the control hasn't the focus (or something similar). If you read the article "MFC ActiveX Control in IE Doesn't Detect Keystrokes" (Q168777) they speak about the activation of the control within IE. I tried their suggestions but I didn't solve my problem. If you have time to check just create an MFC ActiveX control with the wizard (confirm all the default properties and set the "available in insert object dialog"), then add the function OnChar (WM_CHAR) and write inside it AfxMessageBox("Key pressed"). Now insert the object in a VB form and it works, but if you insert in a VC MFC dialog based application (with the wizard) it doesn't work.
I'm using Visual Studio 6.0.
Thanks Paolo.
|
|
|
|
|
How bout playing an mp3? U must need a dll I guess, but where do u get it from and how do u make it work? Does anyone know a site that teaches u this? Thanks anyway!
Serban
|
|
|
|
|
There is an article on CodeProject on skinnable apps that includes C code to play an MP3. It's only drawback is that it isn't C++, it uses globals and therefore cannot be used to play more than one at a time ( I want to find code that does so I can use MP3's in my game sound engine ).
There are a few libraries about, but I don't like not having the source code, and I didn't like the licencing that came with the two libraries I found ( one required payment for any commercial product using the library, which is fair enough but there is no way my employer would pay for something like that, the other was free but reserved the right to become retrospectively expensive, which IMHO is too big a risk to play with at all ).
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|