|
Maybe you can use SetFileTime temporarily set the creation time of file A to some reasonably unique value (in the distant past, for instance) and check the same attribute for file B with GetFileTime . If they are the same, the file is the same. After checking, revert to the original creation time and you're done.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
If e: and f: both "point to" \\machine\share, you could use NetUseGetInfo() or WNetGetConnection() to resolve the path to UNC and then just do a string compare.
char szFile1[MAX_PATH],
szFile2[MAX_PATH];
WNetGetConnection("e:\\pictures\\file1.jpg", szFile1, sizeof(szFile1));
WNetGetConnection("f:\\pictures\\file1.jpg", szFile2, sizeof(szFile2));
bool bSame = (strcmp(szFile1, szFile2) == 0);
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
In My application,I have to implement Tab Views in SplitterWnd.Pl Help me.I tried with examples but I am not able to do that.
pl give an example.
dadsadasd
|
|
|
|
|
Help please!
I used simple wrapper class for the thread. It is just below.
so method ::Start() is used to run it. So some strange thing
is happening. If I call it inside some method
void MyClass::SomeMethod(){
this->p5dev_engine.Start();
...
}
Thread runs but when SomeMethod() is exited, thread does not run too.
But I need it continue to run.
May be did something in wrong way?
class P5DevEngine{
friend DWORD WINAPI DeviceEngineProc(LPVOID lpParameter);
public:
CRITICAL_SECTION csect;
P5DevEngine();
~P5DevEngine();
void Start();
void Stop();
inline BOOL IsRunning(){return running;}
private:
P5Device* p5;
BOOL running;
HANDLE thread;
int thID;
};
static DWORD WINAPI DeviceEngineProc(LPVOID lpParameter){
P5Device* device=(P5Device*)GetP5Device();
P5DevEngine* engine=(P5DevEngine*)lpParameter;
while(TRUE){
EnterCriticalSection(&engine->csect);
device->Cycle(30);
LeaveCriticalSection(&engine->csect);
::Sleep(30);
}
}
P5DevEngine::P5DevEngine(){
InitializeCriticalSection(&csect);
running=FALSE;
thread=NULL;
}
P5DevEngine::~P5DevEngine(){
DeleteCriticalSection(&csect);
}
void P5DevEngine::Start(){
P5Device* dev=(P5Device*)GetP5Device();
if(!dev->IsInited()) dev->Init();
thread=CreateThread(NULL,1,DeviceEngineProc,(LPVOID)this,0,(LPDWORD)thID);
if(thread)
running=TRUE;
else{
running=FALSE;
Error("Can not run thread");
}
}
void P5DevEngine::Stop(){
if(thread){
TerminateThread(thread,0);
running=FALSE;
}
}
|
|
|
|
|
void MyClass::SomeMethod(){
this->p5dev_engine.Start();
...
} I don't know for sure, but if the this object referred to inside MyClass::SomeMethod gets deleted after execution of that member function, the thread most likely will terminate abruptly, as ~P5DevEngine deletes the critical section DeviceEngineProc relies on.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thank you for replay.;););)
Situation is such:
MyClass is not deleted after execution ::SomeMethod().
p5dev_engine is not deleted too.
I tryed use this wothout CriticalSelection.
Behavior does not change.
May be I nedd to pass some flags to CreateThread(...)?
|
|
|
|
|
I've created an app that starts up 4 socket client threads. Before they can even start I need to pass the ip address and port in which they are talking to the socket servers on. Can I pass a struct via windows messages? if so is there a tutorial on how to do this?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Are you using MFC to set up your threads? If so, the solution to your problem dependes on wether the threads are of worker or User Interface type. If the former, you cannot use messages to communicate to the threads, and must rely on some other tecnhique (for instance, Win32 pipes.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
This is an MFC application and I am starting the thread using the AfxBeginThread.
Cannot I not pass a pointer to the structure as the second parameter?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
AfxBeginThread can be used to create worker or UI threads. As you mention the second parameter, I'll assume is the worker variant you're using.
Yes, you can pass a pointer to the structure inside that second parameter. There's one caveat, though, if the struct is dynamically created with new : as you don't know where exactly in time the thread will access the data in the structure, you shouldn't delete it outside the thread:
my_struct * ms=new my_struct(...);
AfxBeginThread(thread_proc,ms,...);
delete ms; the proper way is to let the thread itself delete the data.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
One last thing. Can I pass the same pointer to the multipule threads? Basically at the creation of each thread I will pass a pointer to a struct to that thread, which will contain the ipaddress and port number. Then any time i need to pass info to a thread I'll post a message and have that thread check the struct and grab the data.
Does that sound like it might work. Is there a better way to pass info to a thread after the thread has been created?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I got an Assertation error when i try to allocate the memory. I can't understand the problem because the programm works good when my binary tree is little( i mean 6-th level). Actually i got tree object, and i born a child nodes of this tree, when my level exceeds 6 it shows an error... Where can be the problem???
Visual studio shows me the message box with this message:
file: dlgheap.c
line: 1100
expression _CrtCheckMemory()
Who can explain this situation???
|
|
|
|
|
I’d like to run something like this:
CMutex m;
for( int I = 0; I < 100; I++)
{
m.Load( INFINITE );
//”run a thread” that run m.Unload()
}
my problem is that the second time the main loop runs m.Load(INFINITE )
It doesn’t wait to my thread has runed m.Unload();
What have I missed?
_____________________________
...and justice for all
APe
|
|
|
|
|
In the sample code, you instantiate a new CMutex object. How does the thread get access to the mutex?
Kuphryn
|
|
|
|
|
I (for a start made it totaly Global)
_____________________________
...and justice for all
APe
|
|
|
|
|
d00_ape wrote:
What have I missed?
the principle how mutexes are intended to work
A Mutex protects a resource so that only one thread accesses it at a given time.
A Mutex has two states:
- "Free"
- Acquired by one specific thread
Lock tries to acquire the mutex. It succeeds if
- the Mutex was "Free"
- the Mutex was acquired by the current thread
If it succeeds, the mutex is now acquried by the current thread.
To release the mutex, Unlock must be called:
- in the same thread that called Lock
- the same number of times Lock() was called by this thread
Check the other synchronization objects (I think there was a nice tutorial here on CP) which suit your needs better.
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
peterchen wrote:
To release the mutex, Unlock must be called:
- in the same thread that called Lock
Maybe thats my problem.
I'm tying to release a Global mutex from one of my threads so that the mainthread can continue creating a new thread.
How may I fix that?
Going to read articles on CP - Thanks!!
_____________________________
...and justice for all
APe
|
|
|
|
|
I *think* You could use an event: the main thread waits for it, and the worker thread fires it when appropriate.
However, this is hard to say not knowing all details. And you should be able to make the decision. In my experience, for reliable Multithreaded programming, you have to know "all details" (well, not all, but all your tools)
good luck on the reading
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
OK Thanks!
_____________________________
...and justice for all
APe
|
|
|
|
|
Is there an alogorithm or code sample where I can upsample a wave file? Ie from 8Khz to 11Khz.
Thanks
|
|
|
|
|
That's math search google, there are many examples.
Don't try it, just do it!
|
|
|
|
|
Hi.
My name is Roxanne and I am a C++ / C# programmer.
In the company that I’m working at, we are programming a business program for the customers and the software have been done in Visual C++ 6.0
I have to create and add to the software a new feature pretty similar to: (LiveUpdates from Norton antivirus or another software that check for softwares updates through the internet), to let the customers get the new software’s updates.
Can anyone help me out with some ideas of how to do it?
If somebody can help with some ideas or examples codes I’d appreciate it.
Thanks
Roxanne
|
|
|
|
|
Where is the problem?
Collect all information about the modules used within your software and it's version numbers.
then you could create a php script on the server to parse these version numbers, and if there are new versions then output the urls of the new files. so the client software calls the .php page with the module names and versions as GET parameters and receives the link list of the new files. then download the files and install them. isn't it easy?
Don't try it, just do it!
|
|
|
|
|
thanks Alexander for your help
What customer wants is this.
When they click at LiveUpdates menu, then a dialog box come out and a progress bar star downloading the bytes of the new updates and when it finish then install it.
Do you have any examples or you know some place that I can find one?
Thanks
Roxan
|
|
|
|
|
Or simply a .txt file on the sever that contains all the version numbers/program names.
Download this and parse it, if there is som newer software then download/install it.
"An expert is a person who has made all the mistakes that can be made in a very narrow field." - Neils Bohr
|
|
|
|