|
SAV wrote:
I neet to make a program that scans all hard drives in the local network. How to access the drives int the net? And how to find other comps?
To find other computers take a look at the WNetEnumResource() function, it includes a starting sample. Or you might consider using ADSI (Active Directory Service Interfaces) ?
And as for accessing drives on the net - this is a tough issue. There are many problems involved. But basically you can access any drive on any machine by using UNC paths \\machinename\drivespec. Although in 90% of all cases in proper configured networks this wont suffice.
SAV wrote:
And about CryptoApi. If you have any sources of encrypting/decrypting, please could you send it to me?
Again, the MSDN contains some working samples for this too.
cheers
Andreas
|
|
|
|
|
Hi,
4 DLL's of a large project I'm on have a 8MB+ .bss section, and I'm lost at tracking it back to the cause. Other similar DLL's don't have this, but the affected DLL's make heavy use of some templated library.
excerpt from MAP file:
0003:000001c0 00003560H .data DATA
0003:00003720 008006a4H .bss DATA
0004:00000000 00000cc4H .rsrc$01 DATA
...
0003:00003bf4 ?secAttrDefault@CCRegKey@@2PAU_SECURITY_ATTRIBUTES@@A 004adbf4 cxlibatl:cxRegKey.obj
0003:00803d08 ?_Nilrefs@?$_Tree@VCString@@U?$pair@$$CBVCString@@M@std@@U_Kfn@?$map@VCString@@MU?$less@VCString@@@std@@V?$allocator@M@3@@3@U?$less@VCString@@@3@V?$allocator@M@3@@std@@1IA
00cadd08 FWorkLib:DlgConflict.obj
the secAttrDefault is declared:
class CCRegKey
{
static LPSECURITYATTRIBUTES secAttrDefault;
};
LPSECURITYATTRIBUTES CCRegKey::secAttrDefault;
(and it's unlikely that this is the cause as is, since the class is used in other dll's as well....)
the _NilRefs thing seems to be a map<cstring,???>::allocator member; where CString is a MFC ripoff for use with ATL...
Any ideas where this can come from?
--------------------
don't be surprised if you see this Q in other places as well, yes, it's me...
|
|
|
|
|
Hi everyone. I have a webbrowser2 control on a dialog, with which I am using it to show an html document (a report) my program creates.
I want to stop the control from displaying the properties menu when the user right clicks on it. I found a question someone asked previously about doing this, but I am still not quite sure how to do this. What should I override to do this, and how?
Also, I am using a control bar toolbar of my own on the dialog, and I want to activate the button when the user highlights text, and deactive the button when there is no highlighted text (so the user can copy the text to the clipboard, of course they could hit ctrl-c to copy, but I want to give the user a queue that they can copy off the report to the clipboard). Is there an OnHighlightText type message that does not appear in ClassWizard?
Thanks in advance for any help!
|
|
|
|
|
John Clump wrote:
I want to stop the control from displaying the properties menu when the user right clicks on it. I found a question someone asked previously about doing this, but I am still not quite sure how to do this. What should I override to do this, and how?
If all you want to do is disable the menu and not change it thats easy
IDocHostUIHandler::ShowContextMenu and return S_OK
HTH
Laterz!!!;P
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
why we rarely can find using exception in VC++?
why we rarely can find the "try{ throw }catch()" sentence in VC++
|
|
|
|
|
Because people do not use it ? I only use it if I am doing something where I cannot vouch for my codes ability to run properly, for example, if I am about to try and read a file off the hard drive ( the presence and/or quality of the file are outside my control ).
IMO, using try/catch all the time is a sign you don't think you've written the code properly, and is ugly. It also incurs a performance cost.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
IMO, using try/catch all the time is a sign you don't think you've written the code properly, and is ugly. It also incurs a performance cost.
I don't agree with you here. It may look ugly (on aestethics I won't discuss), and certainly it can incur a performance penalty, but you get the following advantages by using exceptions instead of traditional error codes à la Win32 API:- The performance penalty is usually only incurred when an exception actually is thrown (which is assumed to be rare). The overhead of having a
try/catch block is usually negligible (between 3 and less than 10 asm instructions).
- Exceptions can improve performance and code size in cases where a lot of error codes have to be checked:
if(foo1(...)!=OK){
...
}
if(foo2(...)!=OK){
...
}
...
if(foon(...)!=OK){
...
}
try{
foo1(...);
foo2(...);
...
foon(...);
}
catch(...){
...
}
- Exceptions are sometimes the only reasonable way to go (eg. when a ctor fails).
- Exceptions integrate seamlessly with the RAII (Resource Acquisition Is Initialization) idiom. They help support invariants in your classes.
- They can help you simplify the signatures of your functions: instead of
BOOL getWhatever(int &whatever); or
int getWhatever(); you can write
int getWhatever(); I think the main problem with exceptions is that they came too late to the standard, so a huge set of code is already out there that does not use them. Also, the throw specification in function declarations is basically broken due to backwards compatibility issues. In these respects, newer exception-oriented languages like Java are in a far better position.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
don't agree with you here. It may look ugly (on aestethics I won't discuss), and certainly it can incur a performance penalty, but you get the following advantages by using exceptions instead of traditional error codes à la Win32 API:
I don't think you understood me - I said ALL THE TIME, in other words, I would absolutely use exceptions to detect and respond to errors, but I took the original poster to mean 'why don't more functions get writing using try/catch', and the answer is that quite often there are not a lot of potential errors to catch (sometimes none ) and it just isn't a reasonable thing to do. In that context, I contend that try/catch is very useful, but only in situations where you recognise the possibility of an error. Not every function needs to operate in the context of try/ctach.
I am a vocal advocate of try/catch as an alternative to goto, your example number two is very similar to stuff I have posted many times.
By the way, a BOOL is an int, bool should be used instead.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
I think the guy was asking about using exceptions in general, not wrapping all up in try/catch blocks. Please note that he refers to (quote) "the "try{ throw }catch()" sentence". If he's reading this maybe he can make it clear what was his original intent.
I am a vocal advocate of try/catch as an alternative to goto, your example number two is very similar to stuff I have posted many times.
Good to know we're on the same side.
By the way, a BOOL is an int, bool should be used instead.
Got me (ouch!)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Not sure what you mean. My VC++ code contains many try/throw/catch statements. I often use then in file handling and DAO database I/O.
|
|
|
|
|
I think what he means is (incase you were asking)
Exception handling was included in C++ because C style error checking is almost tedious and would cause confusion to the reader. If you checked the ret value on each function call that would compile into bulky slower code.
if(printf("hey") < NULL)
AfxMessageBox("Error");
Exception handling requires extra type info, which I think is where the slower execution stuff comes in, the crapola is figured out at run time instead of at compile. So I agree with him there, yes it's slower, but I also thought it was the prefered method of error checking. It's the new way.
Besides if you can avoid testing the return on each function certainly this would out-weigh exception handling?
Have a day!!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
G'Day All
I am writing an NT service that uses some MAPI stuff. According to MSDN (and experimentation) it seems that must run without a desktop. Which is fine and indeed I have that part working. However I would like to add some functionality to this service such that it needs to interact with the desktop - specifically I would like it to manipulate the system tray.
Now I believe that system tray manipulation needs a handle to a window but my problem is because the MAPI stuff requires no desktop I don't know how I can grab one. I had tried to enumerate child windows until I found the one I wanted but of course because there is no desktop that call returns no windows.
So I was wondering whether anyone had a good idea as to how best to get around this? Is it possible to have the service start another exe/process/thread to do the manipulation which would have access to the desktop but not place a button on the task bar....
Much thanks for your thoughts,
Richard Ellis.
|
|
|
|
|
Use GetDesktopWindow(). If it returns NULL, it means the desktop is not up yet. Once you have the desktop up, you can do all the tray adding stuff.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Call RegisterWindowMessage(_T("TaskbarCreated")) . That message is broadcast by the shell when the taskbard is created. Use that to tell when you can add your tray icon. (Requires shell 4.71+, however)
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Richard Ellis wrote:
So I was wondering whether anyone had a good idea as to how best to get around this? Is it possible to have the service start another exe/process/thread to do the manipulation which would have access to the desktop but not place a button on the task bar....
Usually when there is need for GUI presence in any non-gui service/driver, the safest solution is just another service which starts after the non-gui one (set dependency in the registry) and use IPC (LPC, pipes, etc.)
cheers
Andreas
|
|
|
|
|
Thankyou very much Gentlemen for your replies.
That was enough to get me searching for a few things I had not thought of. I ended up coming across an article in MSDN that showed me how to create a process from with a NT Service. It seems to work well. FYI my code is below
STARTUPINFO si;
PROCESS_INFORMATION ProcessInformation;
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = NULL;
si.lpDesktop = "WinSta0\\Default";
si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;
if (CreateProcess(NULL, "some exe name", NULL, NULL, FALSE, 0, NULL, NULL, &si, &ProcessInformation))
{
LogText(" process created");
CloseHandle(ProcessInformation.hProcess);
CloseHandle(ProcessInformation.hThread);
} else {
LogText("CreateProcess failed. Error %d\n", GetLastError());
}
Richard Ellis.
|
|
|
|
|
when one MDI view(1) is closed, what happens to another MDI View(2), what message the MDI View(2) will recevie?
one is the other who absorbs the thoughts of others
|
|
|
|
|
WM_MDIACTIVATE is sent for both of the windows. The parameters will indicate which window is losing focus and which window is gaining focus.
|
|
|
|
|
any other chinese programmer in USA ?
|
|
|
|
|
No there isn't...sorry
US Gov't only allows one chinese programmer per country, except China of course
Just teasing...
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
rose:
i am chinese in P.R.China(Tang Dynasty) :
one is the other who absorbs the thoughts of others
|
|
|
|
|
if there is two mdi child windows, one is closed, which message need to be handled to show the caret on the other mdi window? even i don't know how to
process the OnActivateView method.
one is the other who absorbs the thoughts of others
|
|
|
|
|
Hi,
I've got an app with a CListView member in it, and I'nm trying to figure out how to get it to go into "report mode", with say 2 or 3 columns.
I get the underlying list control with GetListCtrl. Then I tried Setting the style, but this seems to have no effect. Am I doing something wrong here?
pListView = (CListView*)m_wndChildSplitter.GetPane(0,1);
CListCtrl& right = pListView->GetListCtrl();
// Turn on the report bit
DWORD dwExStyle = right.GetExtendedStyle();
dwExStyle |= LVS_REPORT;
right.SetExtendedStyle(dwExStyle);
right.InsertColumn(0, "COL1");
right.InsertColumn(1, "COL2");
right.InsertItem(0, "Right", 0);
Thanks
|
|
|
|
|
LVS_REPORT is not an extended style, it's a... not-extended style! You might want to try:
right.ModifyStyle(LVS_LIST | LVS_ICON | LVS_SMALLICON, LVS_REPORT, 0);
Haven't tried it, but hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Thanks!
|
|
|
|