|
What do I use to find all the shared printers on a network. I want to be able to offer the user the choice of netwrok printer in a app setup without having to showw the printer lialog box every time they print.
The second part I have gotten right, no to be able to select the printer
Any help out there?
|
|
|
|
|
tcss wrote: What do I use to find all the shared printers on a network. I want to be able to offer the user the choice of netwrok printer in a app setup without having to showw the printer lialog box every time they print.
try NetServerEnum api
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Use:
DWORD WNetEnumResource(
HANDLE hEnum,
LPDWORD lpcCount,
LPVOID lpBuffer,
LPDWORD lpBufferSize
);
Also see:
NETRESOURCE structure and
DWORD WNetOpenEnum(
DWORD dwScope,
DWORD dwType,
DWORD dwUsage,
LPNETRESOURCE lpNetResource,
LPHANDLE lphEnum
);
this function starts an enumeration of network resources and further you can enumerate by calling WNetEnumResource .
Cheers
"Peace of mind through Technology"
|
|
|
|
|
thanks
Will go away and try this.
|
|
|
|
|
tcss wrote: go away and try this.
Try the Following Code
doEnum(int level, NETRESOURCE *pnr)
{
DWORD rc;
HANDLE hEnum;
CString strTemp;
DWORD count, bufsize, ui;
NETRESOURCE buf[200];
const char *type, *cont;
rc = WNetOpenEnum( RESOURCE_GLOBALNET, RESOURCETYPE_PRINT, 0, pnr, &hEnum );
if ( rc == ERROR_ACCESS_DENIED )
{
return 1;
}
while ( 1 )
{
count = (DWORD) -1L;
bufsize = sizeof buf;
rc = WNetEnumResource( hEnum, &count, buf, &bufsize );
if ( rc != NO_ERROR )
break;
for ( ui = 0; ui < count; ++ ui )
{
switch ( buf[ui].dwDisplayType )
{
case RESOURCEDISPLAYTYPE_DOMAIN:
type = "domain"; break;
case RESOURCEDISPLAYTYPE_GENERIC:
type = "generic"; break;
case RESOURCEDISPLAYTYPE_SERVER:
type = "server"; break;
case RESOURCEDISPLAYTYPE_SHARE:
type = "share"; break;
default:
type = "unknown"; break;
}
cont = ( buf[ui].dwUsage & RESOURCEUSAGE_CONTAINER )? "container": "";
if(level==2)
{
CString networkmachinename;
networkmachinename=buf[ui].lpRemoteName ;
networkmachinename.TrimLeft("\\");
m_machinenames.AddString(networkmachinename);
}
if(level==3)
{
m_sharedfolder.AddString(buf[ui].lpRemoteName);
return 0;
}
if ( buf[ui].dwUsage & RESOURCEUSAGE_CONTAINER)
doEnum( level + 1, &buf[ui] );
}
}
WNetCloseEnum( hEnum );
return 1;
}
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
anyone knows any smart c++ function/library that will convert url type of character entities like those in this one? http://search.targetwords.com/u.search?x=4722%7C1%7C1%7C%7C%7Conline......
i mean %nn sequences. i would like to transform them into characters.
regards
-- modified at 9:29 Monday 22nd May, 2006
|
|
|
|
|
|
scoroop wrote: anyone knows any smart c++ function/library that will convert url type of character entities like those in this one? http://search.targetwords.com/u.search?x=4722%7C1%7C1%7C%7C%7Conline......
i mean %nn sequences. i would like to transform them into characters.
See the following link where you can get the list of URL - encodings
http://www.w3schools.com/tags/ref_urlencode.asp[^]
you may write your own function for same..
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Use UrlUnescape() .
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
scoroop wrote: http://search.targetwords.com/u.search?x=4722%7C1%7C1%7C%7C%7Conline......
try InternetCrackUrl api
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
thanks for all your replies. especially last two should do. i need some extra fuctionality like leaving some sequences untranslated, but that's a minor. i just needed some general guide and what i got is enough.
thanks ones more.
|
|
|
|
|
Hi all,
I have a dialog, and with in a child dialog.
the child dialog has several buttons.
if i stand on them and press the enter key, the main dialog closes.
if i override OnOk() the main dialog isn't closed but the button is not pressed either using the enter key...
any suggestions?
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
YaronNir wrote: I have a dialog, and with in a child dialog.
the child dialog has several buttons.
if i stand on them and press the enter key, the main dialog closes.
if i override OnOk() the main dialog isn't closed but the button is not pressed either using the enter key...
any suggestions?
You can set only one button on the dialog as DEFAULT so that on pressing the enter key that button's Press event happened.
By default OK button is Default button.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
i don't want just one button to be as default, so when i press enter whereever i stand on focus will cause the button to be clicked.
My desire is when i stand on a certain button in the child dialog, and that button has the focus,
pressing enter will cause the button to be clicked (such as pressing space bar does)
thanks
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
|
i know i can operate the button using space bar but
it is common behavior of windows that enter also operate the button
try this
open internet explorer select from menu 'file' then 'properties'.
there is a 'certificates' button there. focus it using tab. then press enter key....
i want the same behavior
thanks
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
|
using setdefid, tells a certain button to be a default button, it means only that button
can be clicked (pressed) using the enter key....
i have several buttons....
any other suggestions?
thanks
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
don't you have a design issue in your GUI ?!
you could always use another event to set the OK button as the default one once the other button was clicked...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
not sure i understand what you mean?
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
YaronNir wrote: My desire is when i stand on a certain button in the child dialog, and that button has the focus,
pressing enter will cause the button to be clicked (such as pressing space bar does)
What about PreTranslateMessage() ?
where you can look for the message "key pressed" and check if it is the 'enter' key. Then GetFocus() to get the current Button and then....;)
Is it clear?
Russell
|
|
|
|
|
Create the dialog in the modeless form rather than the modal dialog. I think this is what you are using;
(Do not forget to change the style of the dialog to child.)
Once you create the dialog in the modeless form you can get the events of the enter key on the buttons of the dialog.
Does this solve your problem or are there some other issues to be met.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
well,
the main dialog is indeed opened as modal, the child dialog are created using create method.
i will try to change the main dialog to be opened as modeless
thanks
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Don't create the main dialog as modal Keep the child dialog as modal
I tried the same and after creating the child dialog as modless i was able to get the code called when the focus was on the button and the enter key was pressed.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
can u send me a code sample?
not sure i understand what you mean
thanks
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|