|
Hi Iain,
Thank you very much for your suggestions. I am trying to go with the second suggestion of yours. I will update this post with my findings..
Thanks
Sheebu
|
|
|
|
|
I have a project which about dns resolver. I need help about this subject. If somebody have any code in c++ or java, please help.
DNS runs over the UDP protocol, and is used to convert user-friendly host names, e.g., www.anadolu.edu.tr, to IP addresses, called the forward translation, or IP addresses to host names, called the reverse translation.
DNS consists of 2 types of messages: Queries and replies.The message (both query and reply) starts with a 12-byte header. The ¯rst 2 bytes contains the message identi¯er, and is used to match replies with queries. Notice that a real DNS resolver may be handling several queries at the same time. Since
all responses will arrive at the same client port, the resolver needs a way to match responses to queries. The message identifier is used for this purpose. Since the resolver will deal with a single query at any time, you may simply set the identifier field to 1 for all your queries. The next 2 bytes is the flags field, and is divided into numerous pieces.
My code should send the the user friendly adress( www.anadolu.edu.tr) to a name server than if i get the answer i will print the ip adresses to the screen. Also my program shoul send the ip address to a server and get the user friendly name to print.
Type of the message should be like this (Query(i sent) and Reply(server sents) messages are same).
12 BYTES HEADER
0-15 (bits) identification:is used to match replies with queries. It is 1 for this project.
16-31(bits) flag field: id divided into fields like below.
QR is a 1-bit ¯eld: 0 means the message is a query, 1 means it is a response.
OPCODE is a 4-bit field: The normal value is 0 (standard query). Other values are 1 (an inverse query), and 2 (server status request).
AA is a 1-bit flag that means "authoritative answer." If the DNS server is authoritative for the queried host, it sets this bit.
TC is a 1-bit flag that means "truncated." With UDP this means the total size of the reply exceeds 512 bytes, and only the first 512 bytes of the reply was returned.
RD is a 1-bit flag that means "recursion desired." This bit can be set in a query and is then returned in the response. This flag tells the name server to handle the query itlsef, called a recursive query. If the bit is not set, and the requested name server does not have an authoritative answer, the requested name server returns a list of other name servers to contact for the answer. This is called an iterative query.
ZERO There is a 3-bit field that must be 0.
RCODE is a 4-bit field with the return code. The common values are 0 (no error) and 3 (name error). A name error is returned only from an authoritative name server and means the domain speci¯ed in query does not exist.
Thanks..
modified on Thursday, October 29, 2009 8:47 AM
|
|
|
|
|
marti86 wrote: I have a project which about dns resolver.
Explain what you mean by this and you'll likely receive more help.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hello .
I want to execute a process at startup of computer before the user has logged on to the machine. How should I do this , I had made a Winlogon pacakage for this but It supports os till Windows 2003 . For later versions of OS including Vista and Windows 2008 where they have removed the concept of Winlogon notify , can any body let me know the alternative for this.
Regards,
Kushagra
modified on Thursday, October 29, 2009 8:59 AM
|
|
|
|
|
I think your stuck with a service .
There's lots of code examples on msdn, and here on codepeject for services, so I'd start your search there.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hi Iain,
I got my solution . What I did was I made my service a part of ServiceGroup (SCSI Class) and by doing this I was able to start my service much before the Login Dialog comes into picture after the system is booted up and thus at this time I checked for Number of active users using api NetWkstaUserEnum . At this time the count comes to be zero and thus I am able to spawn my process at startup of the system even before the user has logged on.
Somebody please mark this answer as this solution works fine.
Regards,
Kushagra
|
|
|
|
|
|
|
I was not aware of the function NetWkstaUserEnum until I read your post. You enlightened me. That's why.
|
|
|
|
|
Oh is it
If it helped it please mark the answer as good so that we can close the thread
Kushagra
|
|
|
|
|
Hi all,
I am working on VC6.
I have a folder path which I have to check whether it is empty or not.
Is there any API to find folder is empty?
Thanks in advance.
Regards,
Sunil Kumar
|
|
|
|
|
sunny_vc wrote: Is there any API to find folder is empty?
I don't know of one that does this directly. I think the only way is to use FindFirstFile()[^] and its associate FindNextFile() to enumerate the directory.
|
|
|
|
|
|
In addition to the other replies pointing you at FindFirstFile, what is empty?
Does it count as empty if there's only directories there? What if there are directories, but they have / have not got any contents themselves?
You don't need to answer me, but you need to ask and answer this question for yourself.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Yeah the case can be considered.
But the directory is created by my application and the files are also created by my
application.
My files doesnt contain any extension.
I do not understand how I can use FindFirstFile.
FindFirstFile is giving me the valid handle.But FindNextFile is always returning 0, even
files are present.
what is the reason behind it?
Regards,
Sunil Kumar
|
|
|
|
|
If you're using MFC you might try something like this:
BOOL DirHasFiles(CString csDir)
{
if (csDir.Right(1) != "\\")
csDir += "\\";
csDir += "*.*";
BOOL bDirHasFiles = FALSE;
CFileFind ff;
BOOL bWorking = ff.FindFile(csDir);
while (bWorking)
{
bWorking = ff.FindNextFile();
if (ff.IsDirectory())
{
if (ff.IsDots())
continue;
}
else
bDirHasFiles == TRUE;
}
return bDirHasFiles;
}
Edit:
For plain WIN32, have a look here:
http://msdn.microsoft.com/en-us/library/aa365200%28VS.85%29.aspx[^]
modified on Thursday, October 29, 2009 8:00 AM
|
|
|
|
|
Thanks a lot Michael.This is exactly what I am looking for.
Regards,
Sunil Kumar
|
|
|
|
|
|
I am using VC++ 6.0.I am not to conversant with VC++.
I have a project where i need to extract the data from the database then provide preview of the same data & then print the same independently. The no. of page could be more than one if the data is more. To achieve this, I have referred to below link for print & preview in MFC. I found this project very useful to cater to my requirement.
http://www.codeproject.com/KB/printing/printlib.aspx
In this project, preview or print button, i am unable to understand how it adds 2nd page. i have a requirement where if data is more than 1 page then it should automatically go to next page. How would i do that in VC++ in the above project.
Kindly indicate if you would need some more info.
|
|
|
|
|
I've done next to nothing in regards to printing via code, but one of the last times I did need to print something, I wrote the contents of my database query to an HTML file, and then navigated to that file using CHtmlView .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I have a client server applicaion. on the server side it uses ISAPI.dll and ilaServer.exe on windows 2000 server with IIS 5.0
build in C++
for some reasons the IIS hangs. and the IIS need to be restarted to set back to work.
I want to know the root cause for this hangs, and analyse the problem and reslove it.
source was in VS 2005. I tried using Dr. Watson Dumps
And tried to analise it in VS 2005, but it is not compatable (VS says it is old version of dump file )
Can you pls help & advice
|
|
|
|
|
Hi,
im creating combobox ctrl dynamically Thru code but not from resource...and Pls let me know how can i increase the height of the ctrl based on the font...ie if the font is small ctrl should be small else if the Font is bigger Ctrl should increase....
i used SetFont() the size of the ctrl is increased and the Font of the items in the Dropdownlist was also increased but the selected item font is not changed...
m_ComboBox.Create(
WS_CHILD|WS_VISIBLE|WS_VSCROLL|CBS_DROPDOWNLIST,
CRect(5, 10, 20, 50),
pParentWnd, IDC_COMBOBOX);
and even i tried using GetComboBoxInfo and obtained HWND hwndItem handle for Editbox but i want to know how can i setfont for the same...
|
|
|
|
|
Just set the font size as mentioned below with m_Font as member.
Doing so will increase the height of the combo box according to the font size and font type
To increase the width, you can SetWindowPos or MoveWindow functions .
CDC *pDC = GetDC();
LOGFONT lFont;
memset(&lFont, 0, sizeof(lFont));
lFont.lfHeight = 34;
lFont.lfWeight = FW_NORMAL;
lFont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
strcpy( lFont.lfFaceName, _T("Lucida Sans Unicode"));
m_Font.CreateFontIndirect(&lFont);
m_pComBo->SetFont(&m_Font);
Величие не Бога может быть недооценена.
modified on Thursday, October 29, 2009 4:15 AM
|
|
|
|
|
You may send the WM_SETFONT message to the the combo's edit box (that is another window), i.e.:
- call
GetComboBoxInfo [^] to obtain the handle of the edit box ( hwndItem member of the COMBOBOXINFO struct ). - Send the
WM_SETFONT message using the found handle.
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]
|
|
|
|
|
I tried using the below code..
COMBOBOXINFO cbi;
cbi.cbSize = sizeof(COMBOBOXINFO);
m_ComboBox.GetComboBoxInfo(&cbi);
::SendMessage(cbi.hwndItem,WM_SETFONT,(WPARAM)pFont->m_hObject,TRUE);
::SendMessage(cbi.hwndCombo,WM_SETFONT,(WPARAM)pFont->m_hObject,TRUE);
::SendMessage(cbi.hwndList,WM_SETFONT,(WPARAM)pFont->m_hObject,TRUE);
Where pFont is a CFont* in which im having the bigger font..
All are changed except the Font in the selected item in the combobox..
The font in the selected item of Combobox is also changed but when i click on the combobox the font of the selected item is changing to older font ie small font...
Please help me regarding the same..
|
|
|
|