|
hello all:
when i use NetWkstaUserGetInfo function
typedef struct _WKSTA_USER_INFO_1 {
LPWSTR wkui1_username;
LPWSTR wkui1_logon_domain;
LPWSTR wkui1_oth_domains;
LPWSTR wkui1_logon_server;
}WKSTA_USER_INFO_1, *PWKSTA_USER_INFO_1, *LPWKSTA_USER_INFO_1;
_WKSTA_USER_INFO_1 t;
char tm[100]={0};
NetWkstaUserGetInfo(NULL,1,(LPBYTE*)(&t));
strcpy(tm,(char*)t.wkui1_username);
"65168" is the t.wkui1_username value
why is not the current user name?
a beginner
|
|
|
|
|
alphaxz wrote: char tm[100]={0};
NetWkstaUserGetInfo(NULL,1,(LPBYTE*)(&t));
strcpy(tm,(char*)t.wkui1_username);
Since Unicode is defined, why not use:
TCHAR tm[100] = {0};
NetWkstaUserGetInfo(NULL, 1, (LPBYTE *) (&t));
_tcscpy_s(tm, _countof(tm), t->wkui1_username); alphaxz wrote: why is not the current user name?
Because t should be a pointer instead:
LPWKSTA_USER_INFO_1 t;
"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
|
|
|
|
|
I can't understand what do you mean?
a struct or a point to a struct ,any difference?
a beginner
|
|
|
|
|
Just take a look at the below piece of code and hope you will be clear..
DWORD dwLevel = 1; // Specifies the information level of the data
LPWKSTA_USER_INFO_1 pBuf = NULL;
NetWkstaUserGetInfo(NULL,
dwLevel,
(LPBYTE *)&pBuf);
The 3rd parameter is the pointer to the buffer that holds the data.
A point to note here is that this function will work only locally and will fail if you try to enumerate the list of remote users...
Regards,
Rane
|
|
|
|
|
thanks all
I've got the answer
the difference between ansi and unicode
a beginner
|
|
|
|
|
alphaxz wrote: I can't understand what do you mean?
I gave you the code. What's not to understand?
alphaxz wrote: a struct or a point to a struct ,any difference?
Yes, a big one. Notice the third argument to NetWkstaUserGetInfo() is supposed to be a BYTE** . The second pointer is there so that NetWkstaUserGetInfo() can allocate memory for the structure.
Don't forget to call NetApiBufferFree() .
"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
|
|
|
|
|
thank u very much
i've got the answer under your instruction
a beginner
|
|
|
|
|
In the parent window, I use a child window to group controls, and want the parent window to handle their messages. In other words, let the child window only deal with position problems. Does Windows have any mechanism that supports this?
system
|
|
|
|
|
I am not sure, but in MFC there is a mechanisam for changing the owner using thr SetOwner() function. That is, the controls send the message to the owner windows. So try specifying the parent window as the owner of the controls.
Optionally you can trap all the messages of the child controls using the PreTranslateMessage() function.
|
|
|
|
|
Hi All,
I am working on Serial port function using NonOverlapped I/O(using VC6.0).
My Application to be communicated with a hardware device with 115200 baud rate.
Im able to receive the data correctly if I place a Sleep(1), in between two characters.
If I remove the Sleep, the data im received is correct for a single write and
Read. If it is continuous the data is corrupted.But If Sleep is there the response time of my application is very slow.
My Code is:
<pre>BOOL PortReadThread (COMMN_CTRL_CLASS *pCCommnCtrl)
{
while (TRUE)
{
// Wait for a character in input buffer
WaitCommEvent(pCCommnCtrl->hCommn, &wEvent, NULL); //from NULL
do
{
// Sleep(1);
wToRead = pCCommnCtrl->ReadPort(&cRcvdByte,1);
if(wToRead>0)
{
Count++;
pCCommnCtrl->CopyRx(cRcvdByte);//process rxbyte
}
}while(Count<1);
}
CloseHandle(pCCommnCtrl->hReadThread);
return TRUE;
}
}
DWORD CCommnCtrl::ReadPort(BYTE *pBuff, DWORD nToRead)
{
if(!(ReadFile(hCommn, pBuff, nToRead, &wsidytesRead, NULL)))
{
if(GetLastError() == ERROR_IO_PENDING)
{
AfxMessageBox("PENDING");
}
else
{
wsidytesRead = 0;
ClearCommError(hCommn, &wErrorFlags, &comstat);
}
}
return wsidytesRead;
}
Communication time outs:
timeout.ReadIntervalTimeout = 0xFFFFFFFF;
timeout.ReadTotalTimeoutMultiplier =0;
timeout.ReadTotalTimeoutConstant = 0;
timeout.WriteTotalTimeoutMultiplier = 0;
timeout.WriteTotalTimeoutConstant = 0;
</pre>
If I place a Sleep(1), in ReadThread then even for continuous read and write the data is correct.But If I remove sleep, the data I receive is very fast but corrupted.
Please clarify If I need to chnage my code.
Regards,
Sunil Kumar
|
|
|
|
|
1/ Something went wrong with your pre tags.
2/ Read Flounder's essay on serial programming - it will hopefully help you avoid a few pitfalls...
http://www.flounder.com/serial.htm[^]
Iain.
|
|
|
|
|
I found this code:
cin.ignore(numeric_limits<streamsize>::max(), '\n');</streamsize>
to clear the input buffer but sometimes when I use it there's nothing in the buffer which results in the program stops and does not continue until I press Enter.
How can I check if there's anything in the buffer before I try to clear to prevent the program from stopping?
|
|
|
|
|
Because cin.ignore(std::numeric_limits::max(),'\n'); means ignore input upto the next newline. If there is no newline pending then you are going to have to input another.
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
Sunday8PM wrote: How can I check if there's anything in the buffer before I try to clear to prevent the program from stopping?
What about cin.clear() or cin.flush() ?
"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
|
|
|
|
|
Those do not clear the input buffer. Maybe clear it is not the word, I want to use cin.ignore but inside an if case telling me if there's anything in the stream.
I just looked at cin.peek() but I'm not sure how to use it, if I understand correcty it shows the next character in the stream but what should I campare the character to?
|
|
|
|
|
This is re-post, as I really could do with some help..
Hi.
I have a simple console app which I use to CreateProcess() other console apps with re-directed output streams so that I can get hold of their output with PeekNamedPipe(). I have just noticed, by accident (which does not say much for my intensive testing) that in the output from the DOS tree command, the nice ASCII angle and bar characters are encoded incorrectly (I think with the default windows encoding). My App is built using MBCS which I understand is OK for ASCII, what do I need to do to get an output identical to the command-line invocation of TREE.
Any thoughts are much appreciated.
James.
|
|
|
|
|
Hi, Mark directed me to the MSDN section about scrollbars this morning which helped a lot, but I still have one problem that I can't seem to solve:
Once again I'm using VC++ with MFC, and I have a CScrollBar that I want to use to scroll some custom controls.
I don't want to use the dialog's "built-in" scrollbar because it isn't in the right place and I have lots of other bits of data there, so I have a stand-alone CScrollBar control that I have mapped through DDX_Control to my dialog.
Since my scrollbar is stand-alone I had to subclass it in order to catch the WM_VSCROLL messages sent to its window when the bar is moved. This all works fine BUT ONLY when I have the scroll bar's style set as WM_VSCROLL. The style SHOULD be SBS_VERT, but when I make the style SBS_VERT instead of WM_VSCROLL, I no longer get any WM_VSCROLL messages in my subclassed process. What could I be doing wrong???
Also on a side note, it seems pretty ridiculous that I have to either subclass the control or overload it and handle OnVScroll explicitly to get the scroll bar to function. Is there a better way?
Thanks!
KR
|
|
|
|
|
You can catch the WM_VSCROLL message in the parent of
the scrollbar control. There's no reason to subclass the
control.
KellyR wrote: ONLY when I have the scroll bar's style set as WM_VSCROLL
WM_VSCROLL is a message, not a style, so it shouldn't be used as a style
If you don't specify SBS_VERT as a style, then the default is SBS_HORZ.
I tested this real quick - Here's all I did:
1) Added a scrollbar control (vertical) to a dialog
2) Right clicked the control and added a control variable (to the dialog's class)
3) Added a WM_VSCROLL handler to the dialog class.
Clicking on the scrollbar control sends a WM_VSCROLL to the parent
as expected.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That's weird, that's the first thing I tried earlier today and it didn't work. I must have done something wrong before because it seems to work now. I thought it was stupid to have to subclass the thing...
Ok, all set, thanks!
KR
|
|
|
|
|
firstly I am unable to append the file in question,
so I load the contents of the file, into an array.
then reopen to write the loaded contents, plus
what I want to append, (from the dialogs edit box).
which works fine, everything is written.
How ever, if I enter some more text, and press ok, however a many of times,
the original contents is written, and the last record enterd is only shown.
for example, the file contents is:
1
2
I enter 3 in the edit box(press ok) then 4
and end the program.
the file contents
is
1
2
4
the update declaration is set to true 'update(true)';
how ever if I set update to false.
the file contents is
1
2
-> only
I am not sure if the file contents have been reloaded and rewritten or not
but changing the update to false, I do not know if this is in any relation
to the program failing to write the subsequent messages
has any body got a clue why this is not working.
perhaps my understanging of how dialogs work is in question.
thanks in advance
Simon
|
|
|
|
|
I am working on an iTunes plugin using their own SDK the only thing I have changed is adding two MessageBoxes. iTunes sends stream information to a function in the plugin where I am able to access it. Here is the code.
case kVisualPluginPlayMessage:
if (messageInfo->u.playMessage.trackInfo != nil)
visualPluginData->trackInfo = *messageInfo->u.playMessage.trackInfoUnicode;
else
MyMemClear(&visualPluginData->trackInfo,sizeof(visualPluginData->trackInfo));
if (messageInfo->u.playMessage.streamInfo != nil)
visualPluginData->streamInfo = *messageInfo->u.playMessage.streamInfoUnicode;
else
MyMemClear(&visualPluginData->streamInfo,sizeof(visualPluginData->streamInfo));
//MessageBox(NULL, visualPluginData->streamInfo.streamTitle, "Stream Title 1", NULL);
MessageBox(NULL, visualPluginData->streamInfo.streamTitle, "Stream Title 2", NULL);
visualPluginData->playing = true;
break;
streamTitle is an str255 variable passed on by iTunes. Now, if I run it like it is it will display nothing for streamTitle. If I run it without the first MessageBox uncommented it will display nothing for streamTitle the first time, but the second MessageBox will have information in it. This is driving me insane haha and any help would be greatly appreciated.
|
|
|
|
|
Can anyone tell me the API I can use so that while my app is running it doesn't allow the OS to go into sleep or suspend mode? What must I do.
Thanks!
|
|
|
|
|
Assuming you're developing on Windows, take a look at the WM_POWERBROADCAST message (docs here) which is sent to all top-level window procedures when a power state is about to change. To prevent Windows going into standby/sleep mode, check whether the wParam is PBT_APMQUERYSUSPEND , and if so, return BROADCAST_QUERY_DENY when processing this message (Win 2k3, Win XP and Win 2k).
However, for Windows Vista, use the SetThreadExecutionState() function (docs here), which can prevent the system entering sleep mode. It is also supported in Win XP and Win 2k Pro.
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
Thanks for the pointers. I did end up using SetThreadExecutionState() as I really didn't need the fine control WndProc and it's power handling functionality offered. Nice and easy.
Cheers!
|
|
|
|
|
I have a TreeView with 8 root nodes in which I want to select / deselect all decedent nodes based on any given node I select / deselect.
I have tried overriding the OnNotify, but have been unsuccessful in trying to get the behavior I want. Currently, the OnNotify only seems to work on the first root node... none of the other sibling root nodes seem to trip the OnNotify. The other problem I'm having is on the one root node that does respond via OnNotify, I cannot traverse its branches to select / deselect node paths I want ignored. All decendant nodes of this one root node only react when the root node is selected / deselected.
This is what I have on the OnNotify:
BOOL CViewFilter::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
if (wParam == IDC_TREE1)
{
HTREEITEM hItem = m_filterTreeCtrl.GetSelectedItem();
if ((hItem != 0) && (m_filterTreeCtrl.GetCheck(hItem) == 0))
{
SetDecendentNodesOff(hItem);
}
else if ((hItem != 0) && (m_filterTreeCtrl.GetCheck(hItem) == 1))
{
SetDecendentNodesOn(hItem);
}
}
return CDialog::OnNotify(wParam, lParam, pResult);
}
Any help would be greatly appreciated.
modified on Thursday, September 4, 2008 1:56 PM
|
|
|
|
|