|
Would it be safer for me to create a class derived from CWinThread and call my thread function in it instead of having a function to call in my main app?
If I leave my thread function in my main app and I wrap a call to a data variable from my main app in a critical section will that still stop other threads from touching that data variable until I unlock it?
One other thing. I have a pointer to an ADO object. the pointer was created in my main app. Since I'm passing a pointer to my dlg class I'm able to pass this object pointer also, to my thread. Can multipule threads use the smae pointer with out using critical section?
m_pConnection->Execute(_bstr_t(mySelect), NULL, NULL);<br />
mySelect is local to the thread function. So in my htread function I would have something like
<br />
myDlg->m_pConnection->Execute(_bstr_t(mySelect), NULL, NULL);<br />
Would this work?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I would be VERY careful about using a pointer to a DAO object or state from multiple threads without some synchronization. For exmaple, what would you expect to happen if all the threads want to 'open' a connection at the same time? If the class stores state information, then all threads are using the same connection, not separate connections any more. If you want them to all access the same database, you might need to be sure that onyl one of them is executing a query at any given time. This might defeat the entire purpose of having multiple threads anyways, and then you would have wished they all had their own separate objects.
|
|
|
|
|
DuplicateTokenEx has this in its remarks:
When you have finished using the new token, call the CloseHandle function to close the token handle.
Okay, so with the DuplicateToken, do you need to close the returned token handle from it as well?
|
|
|
|
|
Blake Miller wrote:
Okay, so with the DuplicateToken, do you need to close the returned token handle from it as well?
Seems so. Here's some sample code from MS (is written for .NET but using the Win32 API), in which CloseHandle is used on a handle returned by DuplicateToken ...
WindowsIdentity.Impersonate Method[^]
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thanks for the quick response.
Also thanks for the sample which validates the answer.
Some in-house testing has showed the handle counts increasing, so we were coming to the same conclusion.
|
|
|
|
|
A couple of weeks back some guys helped me to create a dictionary file. Now I am looking to find a program that would remove duplcate words. I have not found one yet. Would anyone be willing to help me create a program that removes duplicate words? If, yes please have the code in console app format.
Many thanks
|
|
|
|
|
You would at least have to supply enough information to know what the dictionary file's data format is. We cna not remove anything if we don't knwo how to look it up, resport, save, etc. your existing data.
|
|
|
|
|
It is in the format of one word per line. The program takes a text document and scans the file for a space. Every time it finds a space it replaces it with a line return.
|
|
|
|
|
If you feed all your words into a ternary search tree, then enumerate the items in the tree when you are done, you will end up with a sorted list of words with no duplicates.
You can enumerate the tree items and the words can come out in aphabetically ascending order.
|
|
|
|
|
Do you think the ternary search tree will still work if there are 30+ of the same word?
|
|
|
|
|
The ternary search tree will NOT accept duplicates.
It would hold all your words (less running out of memory, but you could also work around that) and there would only be a single copy of each word in the tree.
If you wanted to, you could associate a count with each word, so you would know how many were encountered in each document, but there would only be one copy of each unique word in
the tree itself. That is why I suggested it, you wanted to remove duplicates.
|
|
|
|
|
That's what uniq in Unix systems does. It requires the input file to be sorted, but you can of course pipe sort and uniq .
If command line utilies are acceptable, just download one of the many free kits of Unix tools for DOS/Windows. Then you can do, for example, something like:
C:\somewhere>type yourfile.txt | sort | uniq > output.txt
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
That's what uniq in Unix systems does. It requires the input file to be sorted, but you can of course pipe sort and uniq.
C:\somewhere>type yourfile.txt | sort | uniq > output.txt
Native Win32 ports can be found here: GNU utilities for Win32[^]
|
|
|
|
|
Perl is da bomb for text parsing
while( <> )
{
chomp;
$words{$_} = 1;
}
print join ("\n", sort keys %words);
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
You cannot stop me with paramecium alone!
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
I am trying to use a DLL in my Application . So i have been provided with the following
MyDll.dll
MyDll.h
MyDll.lib
I placed all these under a folder inside my Project called MyDll Files
I added the Library by going into Project-->Settings--> Link Tab and adding
DBusFiles/DBusDrv.lib
Now I am writing a Wrapper classes for the DLL functionality called CMyDllInterface
CMyDllInterface ::CMyDllInterface
{
// Some call to DLL
}
I get a message box with a message (with n different path names ) saying that it couldnt find the DLL . I know that if i put the dll inside WINNT\System32 it will work , but is there a way I can do it the other way ?
Engineering is the effort !
|
|
|
|
|
|
Michael Dunn wrote:
The DLL should go in the same directory as your EXE.
... or anywhere else on your search path. The MSDN description of the ::LoadLibrary() function details the search algorithm.
|
|
|
|
|
searches dll in the following sequence:
The directory from which the application loaded.
The current directory.
Windows 95 and Windows 98: The Windows system directory. Use theGetSystemDirectory function to get the path of this directory.
Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.
Windows NT: The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.
The Windows directory. Use theGetWindowsDirectory function to get the path of this directory.
The directories that are listed in the PATH environment variable.
AntonlioX
|
|
|
|
|
To have string in my application, i can put it inside a .mc file or add it as a string resource(IDS_). So can anyone tell me the difference in these two approach.
Thanks for your time.
|
|
|
|
|
xcavin wrote:
To have string in my application, i can put it inside a .mc file...
Start here for the ins and outs of message files and the message compiler.
xcavin wrote:
...or add it as a string resource(IDS_).
See here for string resources.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
Thanks for the reply.
I think we can have support for multiple language with the same file, have not seen any sample code (multi langs in .mc file) doing that till now.
|
|
|
|
|
sorry for the incomplete question which i putsome days ago.well i just want to develop and application in vc which can change IE settings.By default the radio button that i checked for downloading the file is set to enable i want to change it to prompt.How can i do this.Please tell.Thanks.
Be FaithFull To Your Work.
|
|
|
|
|
can anyone help me in building a explorer bar like that of xp...
k.rajesh
|
|
|
|
|
I've got a CFormView-derived class. It contains a CPropertySheet member, that is, it is not a CPropertySheet-derived class. On one page of the property sheet there is a combobox.
So how can I treat a CBN_SELCHANGE event from that combobox within the View class?
Pseudocode:
<br />
public CMyView : CFormView<br />
{<br />
CPropertySheet* m_sheet;<br />
CPropertyPage* m_page;
}<br />
...<br />
m_sheet->AddPage(m_page);<br />
...<br />
void CMyView::ComboBoxHandlerFcn<br />
{<br />
DoSomething();<br />
}<br />
stevy
|
|
|
|