|
I am trying to do something simple. A user types in a share name of a resource (e.g., \\Mycomputer\MyShare), and I want to validate it to make sure the resource actually exists before going any further.
Apparently, nobody else does this, becuase the documentation for all the Microsoft networking APIs sucks, and there are very few examples on the Net (I couldn't find anything relevant). Here are some of the things I've tried to do so far:
resource.dwType = RESOURCETYPE_PRINT;
resource.lpRemoteName = uncShareName.GetBuffer(0);
size = 0;
error = ::WNetGetResourceInformation(&resource, NULL, &size, NULL);
I always get error code 487 - Invalid address. (Of course, MSDN does not list this as an error that WNetGetResourceInformation should return.)
So then, I tried seeing if I could set the NETRESOURCE's lpProvider and perhaps that would make things go smoother. But this simple code:
DWORD size = 1000;
char provider[1000];
DWORD error;
error = ::WNetGetProviderName(WNNC_NET_MSNET, provider, &size);
always returns an error 1222, network cannot be found (network not present or cannot be found). Apparently my network type is wrong, but there are no others that look anywhere near correct.
For printers, I can use EnumPrinters and get it to work - but only if the remote server is Windows NT, 2000, or XP. It gives me an error, RPC Server unavailable, if I try to look for shares on a 9X machine.
One final piece of the puzzle - I know it is not a networking issue, becuase I can see any object I want using Windows Explorer or "Run" from the Start menu.
Any help would be appreciated.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Ah, nevermind, I figured it out. The key is to use WNetEnumResources.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
I am trying to find a way to display a form from a
Visual studio macro. I have opened the Macro IDE,
but cannot find a way to insert a form. Can anyone
tell me how to do this, or do I need to build an
add in for such a thing? (Coding the macro in VB)
Thanks,
NDP.
|
|
|
|
|
As far as I know, it's not possible in VC6. An add-in is your only option.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I'm sorry, I should have been more specific. I am using
Visual Studio .Net
|
|
|
|
|
The story so far...
Using MSVC 6.0, I've created an MDI MFC application, and selected "Container" compound document support. I also ticked the Active Document container checkbox.
I run the application, and insert an object from a file - an existing Word document - into my document. As expected, it shows the whole Word document in the application.
I then select Print Preview from the menu. The print preview window comes up, showing an empty document. The document content is now spewing out of my printer
So, does anyone know how to fix this so the content goes to the print preview DC, not the printer DC?
Thanks in advance
|
|
|
|
|
Hi,
I am trying to get XP alpha icons working in a ListView. I have created a manifest file which link to comctrl 6 but the XP style icons come out crappy. I have noticed in .NET there is a FlatStyle property that you need to set to FlatStyle.System to get it to work correctly.
How can I make XP Icons show correctly in MFC?
Thanks
Ceri
|
|
|
|
|
I have a bunch of local MyCDlg windows that I made using: MyCDlg* pDlg = new MyCDlg that have their pointers in a stored in a vector. At some point I want to kill all these windows so I cycle through the vector and do
pVec[i]->DestroyWindow()
Right after the destroy is it okay to do "delete pVec[i];" ? Is that the way to do it?
Appreciate your help,
ns
|
|
|
|
|
Yes. I assume they're modeless dialogs.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
yes. Whats wrong with killing modals this way?
Appreciate your help,
ns
|
|
|
|
|
You wrote:
Whats wrong with killing modals this way?
That's like stopping a car by removing its key while driving.
The proper way to force a modal dialog to end itself is to post an IDOK (or IDCANCEL ) WM_COMMAND to it. That will cause the proper cleanup actions to occur. You can then delete the saved pointer to your dialog class.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
thanks.....
Appreciate your help,
ns
|
|
|
|
|
quote: That's like stopping a car by removing its key while driving.
Is this possible at all? Never tried it, lmao
/edit: how do I quote in this forum?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Yes, but take care, if your car has assisted direction you won't be able to turn...
|
|
|
|
|
Gregor S. wrote:
/edit: how do I quote in this forum?
By marking the text in the display above the edit window and clicking 'Quote selected text'.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
There's no such button in Phoenix (Mozilla), but there is in Internet Explorer
modified 12-Sep-18 21:01pm.
|
|
|
|
|
This would surely qualify as a bug in the page?
You can at least try it ).
But isn't Phoenix a linux browser? Heretic!;P
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hi.
I've created a CTreeCtrl with a root and some subitems,
but want to get the 'psztext' member from a TVITEM struct.
MFC already created a pointer:
void ...::OnSelchangedTreeview(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
//My Code
CString strText;
strText = (pNMTreeView->itemNew).pszText;
AfxMessageBox(strText);
}
I seem to get really weird ascii code while displaying the CString. Any1 knows what seems to be the problem?
Greetings
Jens
|
|
|
|
|
|
yes i have done that:
strPrevDate = strDate.Right(4);
tvItem.mask = TVIF_TEXT;
tvItem.pszText = strPrevDate.GetBuffer(3);
tvItem.cchTextMax = 32;
tvInsert.hParent = hRoot;
tvInsert.hInsertAfter = TVI_LAST;
tvInsert.item = tvItem;
hYearItem = m_treeCtrl.InsertItem(&tvInsert);
|
|
|
|
|
Forget about that crap, and try this instead:
CTreeCtrl& tree = GetTreeCtrl();
HTREEITEM hItem = tree.GetSelectedItem();
CString strText = tree.GetItemText(hItem);
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
Hi Alvaro
GetTreeCtrl() didn't work for me, i tried it out like this:
CTreeCtrl* pTreeCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREEVIEW);
HTREEITEM hItem = pTreeCtrl->GetSelectedItem();
CString strText = pTreeCtrl->GetItemText(hItem);
I now get the text correctly, thanks
But now, i want to know with which kind of 'level' we are talking about: root, child or 'child of child'
Any1 any idea?
|
|
|
|
|
I have an application that is getting NULL returned from GlobalAlloc, the error code says "not enough storage avaliable" but that does not make sence.
The application has a working set of 450Mb and a virtual set of 790Mb, my machine has 1Gb of physical ram and 2.5Gb total (including virtual memory).
This error does not happen on a machine with 2Gb of ram.
The request is only for 100Mb.
Any ideas why GlobalAlloc should fail?
Could it be address space?
Are there any compiler/linker flags I can change for MSVC 6?
|
|
|
|
|
Justin Hallet wrote:
Any ideas why GlobalAlloc should fail?
try calling GetLastError .
what are you using for uFlags on the GlobalAlloc call?
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
I have, GetLastError, returns ERROR_NOT_ENOUGH_MEMORY, "Not enough storage is available to process this command."
Call is - GlobalAlloc ( GMEM_MOVEABLE | GMEM_ZEROINIT, aSize ), where size is about, 1048576.
|
|
|
|