|
Thanks, Bhavnani pal!
I have read the article you mentioned. I think it
just contains general information of VSS and does
not teach me how to use the software.
I want to get some guides that teach me how to use
VSS step by step.
Can you help?
Cheers,
George
|
|
|
|
|
I know the ip address of a host and i want to know the name of that host. For this purpose i am using following code:
<code>struct hostent *hp;
unsigned int addr = inet_addr(m_strHost);
hp = gethostbyaddr((char *)&addr,4,AF_INET);
if (hp == NULL )
{
printf("\n Failed: %d",WSAGetLastError());
}
else
{
printf( "%s\n\n", hp->h_name );
}</code>
It is working fine for my LAN that uses ip address of type 192.x.x.x. But the problem occurs when i give the ip address of host over internet. As such sometimes gethostbyaddr is successful and in most cases it fails. It fails with error 11004 (i.e A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall)
Strange that it is happening in office and not at home. Any idea ??? Or any other alternative way to determine host name when ip address is known ???
Strange that it is not failing in all cases. For example, the ipaddress of yahoo.com is: 64.58.79.230. If i give this ip address then, the program runs successful and the hostname returned as: w1.rc.vip.dcx.yahoo.com
But if i give the ip address: 207.219.70.31 (which is that of codeproject.com), then i get error 11004, and gethostbyaddr returns NULL
|
|
|
|
|
Shamoon wrote:
hp = gethostbyaddr((char *)&addr,4,AF_INET);
Hm... better to make a sizeof(addr) instead of putting 4 there...
Shamoon wrote:
It fails with error 11004 (i.e A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall)
Hm... in my book 11004 is:
11004—WSANO_DATA
No data record of the requested type found. This error is also associated with gethostbyname and gethostbyaddr. It indicates that the supplied name was valid but that no data record of the requested type was found with it.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Hi,
I am developing ATL EXE server (multithreaded) which contains std::map that i used to store the data of type structure. This std::map will be accessed by clients (ASP web application) via interfaces provided by the ATL EXE server:
struct ScheduledDevice<br />
{<br />
CComBSTR RefID;<br />
CComBSTR Name;<br />
DATE StartTime;<br />
DATE EndTime;<br />
int Status;<br />
long Command;<br />
};<br />
<br />
typedef map<BSTR, ScheduledDevice> SCHEDULELIST;<br />
SCHEDULELIST m_Schedule;<br />
<br />
HRESULT CMonitorDeviceThread::Add(BSTR DeviceName, DATE StartTime, DATE EndsTime, BSTR RefID)<br />
{<br />
ScheduledDevice obj;<br />
<br />
obj.Name = DeviceName;<br />
obj.StartTime = StartTime;<br />
obj.EndTime = EndsTime;<br />
obj.RefID = RefID;<br />
obj.Status = bookOpenStatus;<br />
<br />
EnterCriticalSection(&cs); <br />
m_Schedule[obj.RefID] = obj;<br />
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}<br />
<br />
HRESULT CMonitorDeviceThread::Cancel(BSTR RefID)<br />
{ <br />
SCHEDULELIST::iterator m_Iterator;<br />
<br />
EnterCriticalSection(&cs); <br />
if( ( m_Iterator = m_Schedule.find( RefID ) ) != m_Schedule.end() ) {<br />
<br />
if ( (*m_Iterator).second.Status == bookExecuteStatus )<br />
return E_FAIL;
<br />
m_Schedule.erase( m_Iterator ); <br />
<br />
} else<br />
return E_INVALIDARG;
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}
At different ATL EXE server thread I will continuosly read and modify the std::map (every 2 seconds).
SCHEDULELIST::iterator m_Iterator;<br />
<br />
EnterCriticalSection(&cs);<br />
<br />
for ( m_Iterator = m_Schedule.begin(); m_Iterator != m_Schedule.end(); m_Iterator++ )<br />
{ <br />
<br />
SYSTEMTIME dtStartTime, dtEndTime, stCurDate;<br />
<br />
VariantTimeToSystemTime( (*m_Iterator).second.StartTime, &dtStartTime );<br />
VariantTimeToSystemTime( (*m_Iterator).second.EndTime, &dtEndTime );<br />
GetLocalTime(&stCurDate);<br />
<br />
CHighTime bookStartTime( dtStartTime ); <br />
CHighTime bookEndTime( dtEndTime ); <br />
CHighTime curTime( stCurDate ); <br />
<br />
CHighTimeSpan sDiffStartTime = bookStartTime - curTime;<br />
CHighTimeSpan sDiffEndTime = bookEndTime - curTime;<br />
<br />
long diffStart = sDiffStartTime.GetTotalMinutes(); <br />
long diffEnd = sDiffEndTime.GetTotalMinutes(); <br />
<br />
if ( ( diffStart == 0 || ( diffStart >= -5 && diffStart <= -1 ) ) && <br />
<br />
(*m_Iterator).second.Status == bookOpenStatus ) {<br />
<br />
(*m_Iterator).second.Status = bookExecuteStatus;<br />
<br />
}<br />
<br />
<br />
if ( ( diffEnd == 0 || ( diffEnd >= -10 && diffEnd <= -1 ) ) && <br />
<br />
(*m_Iterator).second.Status == bookExecuteStatus ) {<br />
<br />
<big>m_Schedule.erase( m_Iterator );</big> <br />
<br />
}<br />
<br />
<br />
}
<br />
LeaveCriticalSection(&cs);
But somehow when I run the application (server and clients) the ATL EXE server just crash! I think the problem occured at std::map.erase method.
I dont how to replace this statement since I need to check all items in std::map to do the validation (get the StartTime/EndTime and compare it with current time).
For info, I've add the std::map item using BSTR unique key (ex: 124568798314). This key represent data in my database application.
Thank u very very much in advance . Any advice, help and suggestions strongly aprreciated.
Regards,
newbie
|
|
|
|
|
once you call erase, the iterator becomes invalid.
erase will return an iterator to the next item.
so your loop looks something like this
for (it=stuff.begin();it!=stuff.end();)
{
bool bKeepThisOne=SomeCondition(it);
if (bKeepThisOne)
++it;
else
it=stuff.erase(it);
}
|
|
|
|
|
I am trying to connect to an SQL server database using the OLE DB templates but am getting above error when linking. The code causing the error is:
hr = m_srcProduct.OpenWithServiceComponents(CLSID_SQLOLEDB, &initStd, 1);
//(m_srcProduct is a CDataSource object)
I have sqloledb.h included in stdafx.h, it has the declaration for CLSID_SQLOLEDB but it is declared extern which I think may be the problem....
//----------------------------------------------------------------------------
// Provider-specific Class Ids
#ifdef DBINITCONSTANTS
// Provider CLSID {0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}
extern const GUID CLSID_SQLOLEDB ={0xc7ff16cL,0x38e3,0x11d0,{0x97,0xab,0x0,0xc0,0x4f,0xc2,0xad,0x98}};
how to fix?
|
|
|
|
|
I have an SDI application with multiple views available. Each view is derived from CFormView and is specified with a unique dialog ID.
My question is how do I change the view from one view to a user select one? I have options off of the menu bar that the user selects, this puts all the view changes inside my CMainFrm class. I don't want to destroy the original view that the application starts with, but after that all of the new views can be destroyed after they are used and moved to a new one.
Any help is appreciated.
-Eric
|
|
|
|
|
|
Anatari,
Thanks for the help. I am having one problem though. When I goto create my new view using te Create method I get a compile error of "Create: cannot access protected member declared in class CFormView"
Here is what I am attempting per the article you suggested.
if(!m_pMyView) MyView is a class derived from CFormView
{
m_pMyView = new CMyView;
m_pMyView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CFrameWnd::rectDefault, AfxGetMainWnd(), AFX_IDW_PANE_FIRST+1, NULL);
}
I am doing this in the OnNewDocument of my Document class. Any ideas why I get this error? I have taken the constructor and destructors of my new Vew class and made them public and removed all the DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros from the header and source files of the class.
-Eric
|
|
|
|
|
You have to override the create method in the CFormView derived class you're trying to show
W. Zayas
|
|
|
|
|
Consider ShowWindow().
Kuphryn
|
|
|
|
|
How do I open a new document in a MDI app without using CView::OnFileNew(). The app supports multiple doc's and I want to be able to open new one's from anywhere. I am sure it is simple. Thank you in advance.
|
|
|
|
|
One solution is CStdioFile.
Kuphryn
|
|
|
|
|
You need a pointer to the document template you want to open a document for. In MFC these templates are stored in a CDocManager class object pointer which is part of your CWinApp object. You could do this:
CDocManager *pDocMan = AfxGetApp()->m_pDocManager;
POSITION pos ;
pos = pDocMan->GetFirstDocPosition();
while (pos)
{
CDocTemplate *pTemplate = pDocMan->GetNextTemplate(pos);
pTemplate->OpenDocumentFile(filename); // or NULL ofr an empty document
}
I may have some of the function names wrong here as its from memory.
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
Roger has one way of doing it...
We use CWinApp::OpenDocumentFile(LPCTSTR lpszFileName). Does the same thing, but automatically.
J
May the bear never have cause to eat you.
|
|
|
|
|
I have VC++ .NET and the class wizard is not working properly. I can't add Code Project code to the application I am working on because the "add member variable" feature is always grayed when I right-click an object in the resource editor. WHY DOES IT DO THAT?! I'M ABOUT READY TO RIP MY COMPUTER APART! Please Send Help! Is it a settings problem, or just Microsoft's way of slowly driving me insane?
-- Steve
|
|
|
|
|
Make sure you have already created a class for the resource you are trying to add member variables to by double clicking on the resource your editing or right clicking and choosing "add class."
- Anatari
|
|
|
|
|
background : I need to be able to handle the close button of a miniframe window of a CControlBar; the only way ( that I Found ), is to hack it in the system with the undocumented : m_pFloatingFrameClass member of CFrameWnd :
if ( pBar )
{
if( !pBar->Create("wow", this, IDC_OBJECT_TOOLBAR) )
{
TRACE0("Failed to create object bar\n");
return -1;
}
pBar->SetBarStyle( pBar->GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );
pBar->EnableDocking( CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT );
EnableDocking(CBRS_ALIGN_ANY);
m_pFloatingFrameClass = RUNTIME_CLASS(FloatingBarFrame);
DockControlBar(pBar, AFX_IDW_DOCKBAR_RIGHT|AFX_IDW_DOCKBAR _LEFT);
pBar->LoadState(s);
}
this works sometimes ( and in another case ) ?!?^!^?!^!%!@@$!@#$!%
question I have, can LoadState of the CControlBar and the LoadBarState of the CFrameWnd break the m_pFloatingFrameClass ? I still don't full understand why it doesn't really work ...
Any ideas ( maybe the turkey will help ! ) ?
Thanks.
Max.
|
|
|
|
|
Well, I moved forward ... I've used this comment[^] to help with the floating minibar thing, it's a bit to much hardcoding, but at least know where everything is ...
Max.
|
|
|
|
|
hiya, how do u tab from one edit box to another edit box on a dialog program, by pressing the 'return (enter) key'??
thanks,
grahamoj.
|
|
|
|
|
you can use GetNextDlgTabItem to find the next control in the tab order. so, override OnKeyDown, when you get a VK_RETURN, find the CWnd for the control that currently has focus, then use GetNextDlgTabItem to find the 'next' control.
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
BOOL CYourDialog::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
CWnd *pWnd = GetFocus() ;
CEdit *pEdit = static_cast<CEdit*>(pWnd) ;
if (pEdit != NULL)
pMsg->wParam = VK_TAB ;
}
return CDialog::PreTranslateMessage(pMsg);
}
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
I'm trying to insert an object from a file into a document. How does the filename get passed to the ole server to open it up to display into the container application.
thanks
|
|
|
|
|
help me for program that a non rectangular splash screen class with Alpha blending (Article discussions)
|
|
|
|
|
The way to do this is to pop up a dialog that is not a regular shape. There are plenty of articles on the web for how to do that.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|