|
Milton KB wrote: Only thing qe need to do is to call Release() on the COM interface. But if it is a Smart pointer you dont have to do that, smart pointer distructor will take care of this. Thats why its smart pointer.
That depends. If you call CoUninitialize() before the smart pointer goes out of scope and hence, has not yet called Release, then you will get a crash, as the call to Release goes off into "I've unloaded that DLL" land.
A trivial fix is to rescope:
CoInitialize(NULL);
{
CComPtr<ifooble> spFoobleThing;
....
}
CoUninitialize();
Steve S
Developer for hire
|
|
|
|
|
thats correct. It is a common mistake COM developers make by putting CoIntialize and Couninitialize in the same function.
cheers...milton kb
|
|
|
|
|
I came accross this great (http://www.codeproject.com/threads/processes.asp?df=100&forumid=4699&exp=0&select=278675) and was wondering if anyone could show how to also output the window title. Any help would be great thx!
|
|
|
|
|
Maybe you can try enumerating all the top level windows using EnumWindows(). And check if the process id matches (Use GetWindowThreadProcessId() ). With the window handle of the process, call GetWindowText() to get the title.
|
|
|
|
|
See here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hey everyone,
I've been looking around for a simple regular expressions thing to impliment into my code. However, the only kind I can find are far too advanced for what I need. I started writing it myself and got through any number of question marks with 1 asterisk. I cannot get any farther.
I only need it to beable to understand * and ?. So, something like comp_*_sales_*_?pav would hit something like comp_toyota_sales_inhouse_mpav.
It just needs to return true or false for the match. Any help or guidance would be amazing.
Thanks,
Mike
Gaming at the GuildofBlades.com is the only way to really experiece the level 99 Soul-Sucking Sword!
|
|
|
|
|
|
If you are looking to roll your own solution, when you encounter a * in the pattern, iterate through each successive character in the string-to-match until the character following the * is encountered. For example:
char *pszPattern = "comp_*_sales_*_?pav";
// if x points here ^
char *pszString = "comp_toyota_sales_inhouse_mpav";
// and y points here ^
// advance x one character to the _, and advance y until that character is encountered
When you encounter a ? in the pattern, iterate through one character in the string-to-match. As long as the next character matches the character following the ?, it matches.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Not sure why no-one else has mentioned it yet, but have you looked into the PathMatchSpec(...) function? It sounds like exactly the kind of functionality you are looking for, which is MS-DOS-style wildcard matching...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi there,
I am trying to use CreateFile to open up a file handle however in some instances it doesnt work. Is there a way to convert a file location string into its exact case-sensitive string?
For example.
lszLogFile = "C:\\TeSt\\TeSt.txt";
HANDLE hLogFile = NULL;
hLogFile = CreateFile(lszLogFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
lszLogFile is the actual parameter that works with create file and a handle is created, however if
lszLogFile = "C:\\test\\test.txt";
Then a handle will not be created. Is there a way to find out what the actual Directory string is?
Thanks guys,
Robbie
-- modified at 13:10 Monday 19th June, 2006
Added the extra backslashes, and no that wasnt the problem.
|
|
|
|
|
Sure your problem is case related, not a lack of \ characters?
Steve S
Developer for hire
|
|
|
|
|
capricious_001 wrote: lszLogFile = "C:\\test\test.txt";
Should be:
lszLogFile = "C:\\test<font size=6>\\</font>test.txt";
Maxwell Chen
|
|
|
|
|
|
The gap is too large!
Maxwell Chen
|
|
|
|
|
|
I'm confused too ...
Maxwell Chen
|
|
|
|
|
toxcct wrote: i can't see any difference
Because the OP has been modified.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: toxcct wrote:
i can't see any difference
Because the OP has been modified.
nope David, because i was joking...
check the joke icon ;)
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
capricious_001 wrote: lszLogFile = "C:\\TeSt\TeSt.txt";
This should be:
lszLogFile = "C:\\TeSt\\TeSt.txt";
capricious_001 wrote: Then a handle will not be created.
Why not? Have you checked the return value of GetLastError() ?
capricious_001 wrote: Is there a way to find out what the actual Directory string is?
It's whatever value you have assigned to lszLogFile .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
lol nono, the path directory is correct. I just forgot the extra backslash in this example.
I tested it. having lszLogFile = "C:\\TeSt\\TeSt.txt"; works rather than having all the characters as lower case. So really the question is how do i retreive the case sensitive file path of that file
-- modified at 13:09 Monday 19th June, 2006
I wrote that piece of code in my original post on the fly. I hate copying and pasting my code because its just too much too read.
|
|
|
|
|
capricious_001 wrote: I hate copying and pasting my code because its just too much too read.
But copy/paste is the preferred method as needless posts can be avoided. You only need to paste the relevant snippets, not an entire program.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
capricious_001 wrote: lszLogFile = "C:\\test\\test.txt";
OK. I've read your modified post.
Now it looks like a "chicken-and-egg" question though.
capricious_001 wrote: Then a handle will not be created. Is there a way to find out what the actual Directory string is?
To retrieve the so-called *exact* file path, you need a valid file handle and pass the valid handle into some API.
To get a file handle without knowing the *exact* case-sensitive path (in your case), you can only input the path in case-insensitive form which results in failure (in your case).
Anyway, my system works very well with both your code snippets. :->
Maxwell Chen
|
|
|
|
|
I used GetLastError() and figured out that it was an issue with my type-casting, but I fixed it lol. Thanks for the help.
|
|
|
|
|
Windows file systems are not case-sensitive. If C:\test\test.txt is failing, it's due to something else, not the case of the letters. Check the value of GetLastError()
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
VB > soccer
|
|
|
|
|
hi everybody,
i am bake bihari from bihar .i have one problem that ,i am write different size of string in file but at reading time i don't know size of string which i have to read
,at time i want to read only one string
|
|
|
|