|
Hello,
for a little project of mine i need to detect the drive letters of USB devices that will be plugged in to the computer. Because i plan to run this app on a server, i write it as a standard windows service. But it seems that it is impossible to recieve the needed notification in a service application, while it works perfectly in a windowed application (see here[^] for the same problem).
Basically i register for the notifications like described in Receiving Device Event Notification in Windows Service(Detecting Hardware Insertion and/or Removal in Service)[^]. The problem is that with that registration i only get a DBT_DEVTYP_DEVICEINTERFACE data structure passed to my handler function, but i need a DBT_DEVTYP_VOLUME instead to read the drive letter from it (remember, i am writing a service application).
I haven't found a way to get the drive letter from the DBT_DEVTYP_DEVICEINTERFACE::dbcc_name like described in Detecting Hardware Insertion and/or Removal[^]
Or do you have any other approach on how to get drive letters of newly plugged in devices in services?
|
|
|
|
|
How to get the net speed of your computer and how to get the current webpage's speed?
up!Please give me some remarks?Or recommond some libraries...
I am not a genius, but shed more sweat!
|
|
|
|
|
Say what?
Perhaps you should define what it is that you want?
Do you want the inter(net) speed of the computer, or the gross/net speed of the computer?
In either case, what on earth do you mean by speed?
As for "the current webpage's speed"
What?!?
|
|
|
|
|
Hi, From the plugin for Outlook, i am sending data to a web server using IXMLHTTPRequest send method in synchronous mode.
The method crashes the application. The crash does not occur when running from the code.Please help and provide me the steps to move on this.Thanks
|
|
|
|
|
<br />
struct Node<br />
{<br />
int data;<br />
Node *next;<br />
};<br />
typedef struct Node Node;<br />
<br />
Node *Reverse(Node *head);<br />
<br />
Node *Merge(Node *head1, Node *head2)<br />
{<br />
if (head1 == NULL)<br />
return head2;<br />
if (head2 == NULL)<br />
return head1;<br />
<br />
Node *head = NULL;<br />
Node *p1 == NULL;<br />
Node *p2 == NULL;<br />
<br />
if (head1->data > head2->data)<br />
{<br />
head->next = head1;<br />
p1 = head1->next;<br />
p2 = head2;<br />
}<br />
<br />
else<br />
{<br />
head->next = head2;<br />
p1 = head1;<br />
p2 = head2 -> data;<br />
}<br />
<br />
<br />
while (p1!=NULL && p2!=NULL)<br />
{<br />
if (p1->data > p2->data)<br />
{<br />
head->next =p1;<br />
head = p1;<br />
p1 = p1->next;<br />
}<br />
else<br />
{<br />
head -next = p2;<br />
head = p2;<br />
p2 = p2->next;<br />
}<br />
}<br />
<br />
while (p1 != NULL)<br />
{<br />
head->next = p1;<br />
head = p1;<br />
p1 = p2->next;<br />
}<br />
while (p2 != NULL)<br />
{<br />
head -next = p2;<br />
head = p2;<br />
p2 = p2->next;<br />
}<br />
return head;<br />
}<br />
|
|
|
|
|
Hi,
please edit your post and add:
1. PRE tags instead of CODE tags, for better readability;
2. a textual description of your linked lists; e.g. is head supposed to contain any data, or is it only pointing to the first real node?
3. a textual description of what Merge is supposed to do (which must include preconditions: what is assumed about its parameters, and what is promissed about its return value). Without it, the only thing anyone can say is "if it compiles, it will do what it will do".
|
|
|
|
|
Hi there everyone,
So I have my DLL that needs to communicate with my app. What I want to do is have the dll send my CWinApp derived class a message, and then the CWinApp should call DoModal with the dialog. Problem is, I've never messed with the app part of mfc, only the dialog class, so I have no clue how to set up the handler for the message. As well, since there is no hWnd yet, I need to use PostThreadMessage instead of the normal SendMessage , but in my DLL I need to get the return value and then continue processing (like there would be with SendMessage /DefWindowProc ).
Any help on how to do so would be nice. ^^
|
|
|
|
|
Sounds like you might have the tail wagging the dog. How is your DLL getting control and "running" to be able to control the application?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I'm using LoadLibrary/GetProcAddress in the InitInstance of my class.
|
|
|
|
|
And when you get the address of the proc in the DLL, I assume you call it? Are you trying to do some kind of plug and play system where you can have a different window depending on which DLL you load? Why not just have a call into the DLL to create the dialog and then return?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Oh, I should've said this in my first post - I'm injecting this dll into selected processes, so the event that has to trigger a dialog box in my app could or could not happen and I don't know when it will happen.
Hope that helps?
|
|
|
|
|
Hi,
i am using ShellExecute to launch a url in the default browser, the same code has been working for a few years now.
all of a sudden one guy is complaining that URLs are not working on his 3 PCs
what happens is ShellExecute is called and "If IE8 is running it opens up the site fine but if no IE8 instance is running a new instance comes up, tries to load the page and just keeps loading and nothing happens"
this is very weird cause its tha same old boilerplate code for ShellExecute
Here is the code
HINSTANCE ret = ShellExecute(NULL, "open", "http://www.google.com", NULL, NULL, SW_SHOWNORMAL);
any ideas are more welcome
thanks for your time
C++ where friends have access to your private members !
|
|
|
|
|
I think your call to ShellExecute has a problem. The third parameter should be the name of the .exe, and the fourth should be the command line parameter; in this case, the URL. What happens if you try this? (It works for me) -
ShellExecute(NULL, _T("open"), _T("iexplore.exe"), _T("http://www.google.com"), NULL, SW_SHOWNORMAL);
L u n a t i c F r i n g e
|
|
|
|
|
That is not what I would expect. Your code is enforcing Internet Explorer as the browser to open a particular URL; putting the URL (or any filename with a file extension association) as the third parameter should call the associated EXE to open that URL/file, similar to a double-click inside Windows Explorer. I suggest you try with a .doc file.
|
|
|
|
|
Luc Pattyn wrote: Your code is enforcing Internet Explorer as the browser
Hadn't thought of that... MS slave that I am. I was thinking IE, not generic browser.
L u n a t i c F r i n g e
|
|
|
|
|
Is there an existing C++ class/function which can translates IP info (such as 123.234.567.333) to country string (or country and state string)?
|
|
|
|
|
Try searching for geolocation database, one example is ip-countryside[^]. Some IP ranges are clearly assigned to a location, for others there is manual labour involved to map them, that's why you would need a database. Adding new functionality to your network application, includeh10?
Cheers
/M
|
|
|
|
|
Hi, guys,
I am using ncurses library on *nix.
I have a while loop that always keep running until a user hits a button that would exit the loop, also it accepts other buttons and in respect to their code, certain actions take place. i have several issues i'd like to fix. first of all, how can i solve this:
[code]
while(cond1)
{
halfdelay(2);
chr = getch();
switch(chr)
{
//code
}
foo(chr);
}
[/code]
if key x was pressed, something would happen, then it would do a certain action, if nothing was pressed, it would continue doing that action in respect to they previous char (in this case, char x). if key(char) x was hit again, it should ignore it (without significant pause) and continue doing foo() in respect to key x.
my problem is that pause.
problem 2: since i have that pause, if a user woudl decide to do a silly action and hold key x for long time (not a single quick key hit, but hoding it), obviously the action would be paused for that moment. how can i eliminate that problem?
any hints, please?
thanks
modified 1-Aug-19 21:02pm.
|
|
|
|
|
I want to begin to learn how to do visual gui programs in VC++. I am good with c/c++. To get myself starting I would like to write an app that simply receives messsages over a tcp connection and displays them to a scrolling window. The window should automatically scroll down as new messages are added. But the user should have the ability to scroll back as well.
Any suggestions on how to approach this? Also, as a follow on project I'll want to display data in row/column format and be able to update cells as changes are received over a tcp connection.
Thanks
|
|
|
|
|
Do you know how to do the "receive tcp message" stuff (code and implementation) ?
if you know how to do that, then the rest is quite simple.
Create a worker thread that will receive the data; when the data is received, send a message to the main UI thread (
Create a simple UI thread (main UI, do not create and manage UI in the worker thread)that contains either a CListBox or a CListCtrl. implement handlers for the messages sent by the worker thread.
good luck.
M.
Watched code never compiles.
|
|
|
|
|
Thanks. Anything I need to be careful to select or not to select when I create the project in VC? When you say implement handlers, do you mean each message gets it own handle and is processed from that perspective?
|
|
|
|
|
I would suggest you forget about the TCP stuff until you have mastered the text viewer and scrolling. Whether you use simple Win32 or MFC this can be quite a challenge and TCP would only complicate matters. Start with a view window and add the scroll features then add a mechanism to send some lines of text, say up to 100 and see that your scrolling is working. Then when you have all those features under control you can start to add the more complex pieces of the TCP feed.
It's time for a new signature.
|
|
|
|
|
Alan Kurlansky wrote: To get myself starting I would like to write an app that simply receives messsages over a tcp connection and displays them to a scrolling window.
Hi Alan! I suggest an alternative approach without multi threading to get up and running quickly:
1) create a new MFC project and add a CListBox control: Using the CListBox control[^], this comes with a working example dialog project.
2) Add a TCP client socket such as CAsyncSocket to your dialog: Socket Programming with MFC (Part 1)[^], this will also explain which initialisation is needed in your application.
3) Add a button to your dialog so you can connect/disconnect to a server.
The client will tell you in its OnReceive()[^] handler when more data is available, you can add this to the listbox with AddString()[^] and scroll listbox with SendMessage(WM_VSCROLL, SB_BOTTOM, NULL) . There are many ways to communicate between socket and GUI, for starters you could give the socket object a pointer to your dialog. For example with a method OnReceiveText() that you call from your socket whenever a full text line is available:
void CMyDlg::OnReceiveText(const char* szText)
{
m_listbox.AddString(szText);
m_output.SendMessage(WM_VSCROLL, SB_BOTTOM, NULL);
while(m_output.GetCount() > 10000) m_output.DeleteString(0);
}
Hope this helps
/Moak
|
|
|
|
|
|
ozmrdn wrote: Its my home work
Then it's for you to do the work. Don't expect other people to do it for you.
It's time for a new signature.
|
|
|
|