|
|
Thanks david for quick answer.
I was looking for PNP functions and references you pointed.
Definitely these API's looks promising to find PNP device Id.
However, how I can map my volume (drive letter) to its PNP device Id.
neither of functions actually refer for volume drive letter.
thanks-
Prashanth
|
|
|
|
|
|
Thanks david for quick reply.
I was able to enumerate all the device ID's with the above calls.
Definitely this is good progress for what I am looking.
However, none of the API's are actually refering the device id to the respective volume drives.
For example, if I could enumerate CDRom drives device id's, there is no way to know their volume drive letters.
In other way, volume information and corresponding device info are not related with these API's.
If you open "Device Manager" and select any disc drive, open properties and then volumes tab,
this will not list all the volumes by default.
However when you select "Populate", it is displaying all the volumes in the respective drive.
This is what exactly I am looking.
Either I should know volumes mounted on particular "Device ID" (or) get the device id for a given volume letter.
I dont know how "device manager" is populating drives with the device id?
Any thoughts or pointers?
Thanks-
Prashanth Jaligama
|
|
|
|
|
HI David,
thanks for all your pointers.
I am able to successfully enumerate volumes and their corresponding Device information using SetupDI functions.
1. SetupDI functions will list all devices for given class guid, such as disks, cdroms, volumes.
We can also query for its device number using IOCTL_STORAGE_GET_DEVICE_NUMBER.
2. Separately, all volumes can be retrieved using windows APIs, such as GetLogicalDrives, and then we can also query its device number using same IOCTL_STORAGE_DEVICE_NUMBER on drive letter (ex: \\\\?\\c .
Now I mapped device number in setupDI with the device number retrieved using volumes functions, which allows me to get both volume information and also its corresponding device information.
Of course, device number does not persist across boots, but my little software will keep refresh to map volume drives and its corresponding device info.
thanks-
Prashanth Jaligama
|
|
|
|
|
I read the Clipboard documentation on MSDN!
My application is listening in!
I'm running a timer to check if any text is stored in the Clipboard!
But it didn't detect any strings I copied from my browser!
However when I copied a md5 hash file, my timer went berserk informing it had found more than 1 clipboard data type.
OpenClipboard(Window);
if (!IsClipboardFormatAvailable(CF_TEXT))
Tu(L"ANSI Text!");
if (!IsClipboardFormatAvailable(CF_UNICODETEXT))
Tu(L"Unicode Text!");
if (!IsClipboardFormatAvailable(CF_OEMTEXT))
Tu(L"OEM");
CloseClipboard();
|
|
|
|
|
So what exactly is the question?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Im trying to program a URL catcher.
|
|
|
|
|
Fareed Rizkalla wrote: ...a URL catcher.
Who is throwing them?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
What do you mean who is throwing them?
I initialized my application to listen on the Clipboard.
Then I created a timer that would open the Clipboard to check if their is a URL it could use.
So my timer opens the Clipboard and checks if their is a certain data type stored in it.
However I was unable to detect the URLs I copied from my browser as CF_TEXT, CF_UNICODE and CF_OEMTEXT.
However when I copied a MD5 checksum file it triggered all of the above data types as available.
|
|
|
|
|
Fareed Rizkalla wrote: Then I created a timer that would open the Clipboard to check if their is a URL it could use.
So my timer opens the Clipboard and checks if their is a certain data type stored in it.
Why not call EnumClipboardFormats() to see what formats are currently available?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
You have ! in front of the IsClipboardFormatAvailable() calls, which looks wrong.
--Mike--
|
|
|
|
|
It can be send data to remote server from CString ?
Here is "original code" :
bool CSmtp::SendData()
{
int idx = 0,res,nLeft = strlen(SendBuf);
assert(SendBuf);
if(RecvBuf == NULL)
return false;
while(nLeft > 0)
{
if( res = send(hSocket,&SendBuf[idx],nLeft,0) == SOCKET_ERROR)
{
m_oError = CSMTP_WSA_SEND;
return false;
}
if(!res)
break;
nLeft -= res;
idx += res;
}
return true;
}
which I want to convert into :
BOOL CSmtp::SendData()
{
if(send(m_hSocket,m_sSendBuf,1024,0) == == SOCKET_ERROR)
{
m_nError = CSMTP_WSA_SEND;
return FALSE;
}
return TRUE;
}
m_sSendBuf is CString data member
|
|
|
|
|
mesajflaviu wrote: if(send(m_hSocket,m_sSendBuf,1024,0) == == SOCKET_ERROR)
I would use
if ( send( m_hSocket, m_sSendBuf, m_sSendBuf.GetLength(), 0) == SOCKET_ERROR)
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]
|
|
|
|
|
You haven't mentioned what exactly you're problem is.
Is there a compiler error or is the data not being sent correctly?
There is a chance that you get a compiler error because the send function takes a const char* parameter and a CString in UNICODE builds contains a wchar_t array.
If this is a problem use CStringA explicitly.
CStringA sSendBuf = m_sSendBuf;
send(m_hSocket, sSendBuf, sSendBuf.GetLength(), 0);
|
|
|
|
|
Thank you all , seems to work !!! You make a happy man !
|
|
|
|
|
I use the PickIconDlg function that returns the path to module and index # of icon.
How can I get the resource id of that icon?
Thanks
|
|
|
|
|
I want to use google translator through an application I wrote the following code but it always time out what's my problem.
CString szTranReq(L"/translate_a/t?client=t&sl=en&tl=tr");
CString szText(L"text=Hello");
CString szServer(L"www.google.com");
DWORD inetPort = 80;
CInternetSession inetSession(::AfxGetAppName(), 1, PRE_CONFIG_INTERNET_ACCESS, NULL, NULL, NULL);
inetSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 1000 * 3);
inetSession.SetOption(INTERNET_OPTION_CONNECT_BACKOFF, 1000);
inetSession.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 1);
CHttpConnection* pInetHttpConnection = inetSession.GetHttpConnection(szServer, inetPort, NULL, NULL);
CHttpFile* pHttpFile = pInetHttpConnection->OpenRequest(
CHttpConnection::HTTP_VERB_POST,
szTranReq, NULL, 1, NULL, NULL,
INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_DONT_CACHE);
pHttpFile->AddRequestHeaders(L"Host: www.google.com\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"User-Agent: Mozilla/5.0\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"Accept-Encoding: deflate\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"content-length: 10\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"Connection: Close\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->SendRequest();
DWORD dwRet;
pHttpFile->QueryInfoStatusCode(dwRet);
SendRequest() Method always timeout.
|
|
|
|
|
Hi,
I know that rich edit controls have thier own interface
but would any one know which of the CDC
methods are available and at what point
to a rich edit
Specfically I would like to set the Font and
text Color initially
|
|
|
|
|
A device context is used to render the content of the richedit to a device to intialise the width for word breaks.
use CRichEditCtrl::SetDefaultCharFormat to set the default format of the text.
It takes a CHARFORMAT2 to structure where you can set the font and the textcolor.
Remember to initialize the cbSize with the size of CHARFORMAT2 and to set the dwMask Member to flag which properties you want to set.
Use CRichEditCtrl::SetSelectionCharFormat() to format the selected text.
When set SetWordWrapMode() you should also call SetTargetDevice to set the width of a line.
Use FormatRange to render the content to a device.
|
|
|
|
|
In other words all these Richedit methods act as interface
to CClientDC object
|
|
|
|
|
I didn't get you real question!
CRichEditCtrl is a control an displays its content in the wm_paint event to the paint dc.
Only if the control should calculate sizes or draw it's content a device context is needed.
If you require a "WYSIWYG" you should apply the device context of the desired device.
If you want to calculate the size or want to draw it to a context you have to call FormatRange Method and apply the deviceContext of the target device to the formatrange structure.
If you want to learn, how richeditctrl realy works, see MSDN : Rich Edit Control Examples[^]
|
|
|
|
|
Thought if you wanted to CDC::SetTextColor you would need need ther Device COntext but like you said in a Earlier post you can use
SetCharformat for that
|
|
|
|
|
How can receive data from server , with Windows Sockets recv(SOCKET s,char FAR* buf,int len,int flags); function , into CString object ? Here is my trial :
BOOL CSmtp::ReceiveData()
{
if(recv(m_hSocket,&m_sRecvBuf,m_sRecvBuf.GetLength(),0) == SOCKET_ERROR)
{
m_nError = CSMTP_WSA_RECV;
return FALSE;
}
return TRUE;
}
m_sRecvBuf is member CString data
|
|
|
|
|
Supposing you are doing a ANSI build, this is one of the rare occasion where GetBuffer method is appropriate, for instance:
...
int result = recv( m_hSocket, m_sRecvBuf.GetBuffer(N), N, 0);
m_sRecvBuf.ReleaseBuffer();
if(result == SOCKET_ERROR)
{
..
}
...
where N is the number of requested bytes (number of your choice).
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]
|
|
|
|