|
Its not a local printer. Its one of the printers hanging of the print server, that was returned in the EnumPrinters call.
Are you saying if I want to install a shared network printer, I still need to pass NULL to this function? (Just noticed I was passing the printer name instead of the server name anyway)
The call still fails using the print server name of NULL...
|
|
|
|
|
I assumed you were trying to copy the connected (network) printers for some reason. You enumerate the printers, then loop through and add them all again, it looks like to me.
|
|
|
|
|
What I'm trying to do is programmatically add network printers to a local terminal (minimum. 2K).
Am I going about it the right way?
|
|
|
|
|
I don't understand what you're trying to do. The printers are already connected (or else EnumPrinters wouldn't find them). Why do you need to connect to them again?
|
|
|
|
|
I need to programatically allow certain users access to the printers attached to the server.
If they're not authorised then they can't see the printers.
The printers are connected to the server and I want to bypass the usual way you would add a network printer via the GUI.
|
|
|
|
|
I am using CProperySheet and CPropertyPage in my application for creating tabbed dialog boxes.
For providing the RTL layout, I am using the WS_EX_LAYOUTRTL for Property Sheet and Property Pages both.
This is doing well.
The Titla bar ( System control and min/max/restore buttons) are now in RTL layout.
Tabs contents are also in RTL layout. However two issues are still remaining opened-
1. OK and CANCEL buttons (that were in the Right Side of the screen before applying WS_EX_LAYOUTRTL style) are now in the Middle of the screen. They should be in the Left of the screen.
(Point to notice is that i have hide the "Help" and "Apply" buttons.)
2. Tabs (Tab Bar) are still coming in the Left side of the screen. No effect of the RTL layout on the tabs (Tab Bar) alignment or in their order.
<br />
void CAllControlsSheet::AddControlPages()<br />
{<br />
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);<br />
m_psh.dwFlags |= PSP_USEHICON;<br />
m_psh.hIcon = m_hIcon;<br />
m_psh.dwFlags |= PSH_NOAPPLYNOW;
m_psh.dwFlags |= PSH_RTLREADING ; <br />
m_psh.dwFlags &= ~PSH_HASHELP;
<br />
Invalidate();<br />
<br />
AddPage(&m_treectrlpage);<br />
AddPage(&m_animctrlpage);<br />
AddPage(&m_toolbarpage);<br />
AddPage(&m_datetimepage);<br />
AddPage(&m_monthcalpage);<br />
<br />
}<br />
<br />
BEGIN_MESSAGE_MAP(CAllControlsSheet, CPropertySheet)<br />
ON_WM_QUERYDRAGICON()<br />
ON_WM_SYSCOMMAND()<br />
END_MESSAGE_MAP()<br />
<br />
<br />
BOOL CAllControlsSheet::OnInitDialog()<br />
{<br />
<br />
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);<br />
ASSERT(IDM_ABOUTBOX < 0xF000);<br />
<br />
CMenu* pSysMenu = GetSystemMenu(FALSE);<br />
if (pSysMenu != NULL)<br />
{<br />
CString strAboutMenu;<br />
strAboutMenu.LoadString(IDS_ABOUTBOX);<br />
if (!strAboutMenu.IsEmpty())<br />
{<br />
pSysMenu->AppendMenu(MF_SEPARATOR);<br />
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);<br />
}<br />
}<br />
<br />
SetIcon(m_hIcon, TRUE);<br />
SetIcon(m_hIcon, FALSE);<br />
ModifyStyleEx(0, WS_EX_LAYOUTRTL); <br />
return CPropertySheet::OnInitDialog();<br />
}<br />
<br />
|
|
|
|
|
How can I do it ?
Trying with the following code is not helpful :
<br />
wofstream fout;<br />
fout.open(fileTo, ios_base::out | ios_base::trunc | ios_base::binary);<br />
fout << content.c_str();<br />
fout << flush;<br />
fout.close();<br />
(where content is of type std::wstring)
Are there special header characters I need to insert in order to indicate to a standard UTF-8 text file reader (such as NotePad) that the file is actually encoded in UTF-8 ??
Thank you in advance.
modified on Wednesday, January 14, 2009 1:09 PM
|
|
|
|
|
Here's one way:
wstring content = L"Test String";
ofstream fout;
fout.open("e:\\testutf8.txt", ios_base::out | ios_base::trunc | ios_base::binary);
fout.write("\xEF\xBB\xBF", 3);
int bufsize = ::WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, NULL, 0, NULL, NULL);
LPSTR buf = new CHAR[bufsize];
bufsize = ::WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, buf, bufsize, NULL, NULL);
fout.write(buf, bufsize-1);
fout << flush;
fout.close();
delete[] buf;
That should match what Notepad writes.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello Mark,
Thank you very much it works fine.
I did many ways but all were in vain. Main reason was because I convinced my self that it has necessarily to be done
through an wofstreamù instead of ofstream in order to handle the std::wstring content..
many thanks indeed.
|
|
|
|
|
hINTModuleState wrote: through an wofstreamù instead of ofstream in order to handle the std::wstring content..
There's probably a way to do the conversion to UTF-8 using the wcstombs()
function but I just went with what I know...
just go straight to the conversion API and write the result as a binary byte stream
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a simple server app that uses WritePrivateProfileString() when a client changes the status of a user. I want to protect against multiple 'change status' requests resulting in clashing file writes.
The clients communicate with the server using UDP and the server uses a listener socket. The listener socket uses 'OnReceive()' to call a function to write to the data file.
I've been using a temp file to write to and then delete the working file then rename the temp file. It works most of the time but once in a while the main data file is deleted and there is no temp file. It's a bug but I'm wondering if there is a better way?
Thank you.
|
|
|
|
|
Does each client get serviced on a separate thread by the server? If yes, you'll need to use some kind of synchronization object while writing to the file. A CRITICAL_SECTION might do nicely for you.
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
I'm using a single instance of the listener socket. Would that be enough to ensure the file is only written by one client at a time?
|
|
|
|
|
What do you do when your "accept" (or the equivalent Windows socket extensions API) call returns? Do you launch another thread to respond to the client socket returned by "accept"? If you are doing it on the same thread as the one that invokes "accept" then you shouldn't require synchronization; in which case the problem lies elsewhere.
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
I have a pointer to the server object (the object that created the listener socket), and I call a function in that server object. No additional threads.
Thank you for your time on this.
|
|
|
|
|
OK. You might want to conduct a little experiment. From your "OnReceive" handler, trace the return value of "GetCurrentThreadId" to a log and have multiple clients connect simultaneously to the server. Now inspect the log to see if the values logged are the same for all the clients.
Also, is there a code snippet that you can post that shows how you are doing the file processing?
|
|
|
|
|
CORBA::Boolean CScope::Fineroot
(
IlAdapter::BaseTable*& corbaTexts,
{
corbaTexts = new IlAdapter::BaseTable;
if (result)
{
}
return result;
}
modified on Monday, January 12, 2009 8:53 AM
|
|
|
|
|
Please read Chris's "how to get someone to care enough to answer your question" rules.
One of them mentions the pre tag.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Giving a real answer...
We can have no idea when to delete the memory you just new ed. You're showing a member function that makes a new object for you.
The answer to your question depends on the code that calls this function. We have no idea about that.
result is not defined, and not shown where it comes from either.
I know we're clever in this forum, but we're not gods. (OK, CPallini might be)
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: OK, CPallini might be
Always mocking that poor guy!
BTW: Do you know my new site, www.free.techie.god.answerz.com?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Me think it should be at least in the caller of the method CScope::Fineroot .
It depends where the data will used and how low should it life should be.
|
|
|
|
|
ptr_Electron wrote: CORBA
Ok, there is the problem . No seriously, doing memory management in CORBA is really a pain. If you don't even understand the basic concepts of memory management in C++, then you'll be in great troubles. If you really wants to understand things a bit more in details, you really have to read a book on CORBA and understand it, otherwise you'll be completely lost. And almost nobody here will be able to help you because it's too specific to your application.
Good luck...
|
|
|
|
|
If you are not going to use it outside the Fineroot function, then delete it at the end.
The actual confusion is that you are not showing us what you are gonna do with corbaTexts. If you're going to use it outside the scope of this function, delete it at the place where it will be used (and *after* it is used).
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi.....
I have a small problem in getting the hostname of the mapped drive.
I have mapped a shared folder of a machine in network on my system.
I have to get the name of the machine from the mapped drive.
I was not able to find any proper function for that.
Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out?
Please do help me out.
Thnx in advance...
|
|
|
|
|
raesa wrote: Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out?
Have you tried WNetGetConnection() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|