|
If you really need to provide message handling stuff in classes not derived from CWnd, you may want to use CSubclassWnd by Paul DiLascia (the guy who writes C++ QA column in MSDN Magazine). Just search for CSubclassWnd in MSDN.
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Dear all,
I created a subfolder1 under a shared folder1 which was shared to all users
exp: \\server1\shared folder1\shared subfolder1\
then i need to shared this subfolder1 to a specific user, so i need the local path of this subfolder1 to implement network share
how can i get local path from \\server1\shared folder1??
Thanks for your help.
Tida
|
|
|
|
|
You can use NetShareGetInfo
If you're running on Windows NT/2K/XP you can use level 2 and a structure of type SHARE_INFO_2;
on Windows 9x/ME level 50 and pass in a structure of type share_info_50.
The two structures unfortunately are defined in two different header files and, if you're targeting win9x you'll also need to link to a different library (netapi32.lib for NT/2K/XP and svrapi.lib for 9x)
Hope that helps,
Alberto
|
|
|
|
|
How do I compile Visual C++ .NET projects using the .vcproj file from the command line?
Thanks,
James
|
|
|
|
|
<disclaimer>I've not tried this with VS.NET, just VS6 where it worked a treat</disclaimer>
1. In a command prompt window, execute the vcvars.bat file in the Visual Studio .NET folder\VC7\bin folder. (i.e. Set up environment variables etc)
2. Try the command devenv /build .vcproj filename . If you do devenv /? , it shows you the command line parameters.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Hi all,
Does anyone know if it is possible, when dialling up the internet with a modem, to run local applications using the login script (the one typically used to provide information to the ISP) so that, when the system dials, an application runs - instaed of having a system that polls the port to see if there's a connection.
Thanks,
Alberto Giannetto
|
|
|
|
|
I am repeatedly accessing this function in my database app:
void CTrain1View::GetPhotoDB(CString m_PhotoDBName,CString m_MineName)
{
if (m_photoDb.IsOpen()) m_photoDb.Close();
m_photoDb.OpenPhotoDb(m_PhotoDBName, m_MineName);
}
where
int DbClass::OpenPhotoDb(CString PhotoDBName, CString MineName)
{
try
{
if (FAILED (m_pConnPhoto->Open (_bstr_t ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "+ PhotoDBName ),_bstr_t (""), _bstr_t (""), adModeUnknown)))
{
AfxMessageBox ("Can't open datasource");
return -1;
}
CString partQuery = "'"+MineName+"'";
CString SQLQ = "SELECT * FROM tblMine WHERE (DefID = "+partQuery+")";
char* SQLQuery = new char [SQLQ.GetLength()+1];
strcpy(SQLQuery, SQLQ);
m_pCommandPhoto->ActiveConnection = m_pConnPhoto;
m_pCommandPhoto->CommandText= SQLQuery;
m_pRecordsetPhoto->CursorLocation = adUseClient;
m_pRecordsetPhoto->Open ((IDispatch *) m_pCommandPhoto, vtMissing, adOpenKeyset,
adLockOptimistic, -1);
delete[] SQLQuery;
return num;
}
catch(_com_error)
{
PrintProviderError(m_pConn);
}
}
The second time I call the first function, and it calls OpenPhotoDB, there is a com error at:
if (FAILED (m_pConnPhoto->Open (_bstr_t ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "+ PhotoDBName ),_bstr_t (""), _bstr_t (""), adModeUnknown)))
{
AfxMessageBox ("Can't open datasource");
return -1;
}
even though as you can see, I did close the db before trying to open it again. Any one know ADO to help me out. I'm opening and then closing it before trying to open it again, so why does it choke?
Thanks,
ns
|
|
|
|
|
First of all why are you closing the database connection prior to each query? This is a very inefficient way for your code to work. It should be more like if db.closed thhen db.open(). You should use the open database connection to execute as many queries you want.
This will not solve your current problem but will make your code more efficient, unless I missed something while reading your message.
|
|
|
|
|
Okay - so I should open the database just once and perform as many queries as Ilike on it. Right?
The reason I want to close and reopen is that most of the time its the same db, but sometimes the a different db name to open might come in as a parameter.
What about the recordset object. Since I do rs.Open for each query, should I close it each time and reopen it I pass it a new SQL string?
Thanks
ns
|
|
|
|
|
None of the messsageboxes fire, the program execution merrily skips past the called function and goes on!
THe error checking in place is:
void PrintProviderError(_ConnectionPtr pConnection)
{
HRESULT hr = S_OK;
_bstr_t strError;
ErrorPtr pErr = NULL;
try
{
long nCount = pConnection->Errors->Count;
for(long i = 0; i < nCount; i++)
{
pErr = pConnection->Errors->GetItem(i);
CString temp;
temp.Format("Error #%d\n", pErr->Number);
AfxMessageBox(temp);
temp.Format(" %s\n",(LPCSTR)pErr->Description);
AfxMessageBox(temp);
temp.Format(" (Source: %s)\n",(LPCSTR)pErr->Source);
AfxMessageBox(temp);
temp.Format(" (SQL State: %s)\n",(LPCSTR)pErr->SQLState);
AfxMessageBox(temp);
temp.Format(" (NativeError: %d)\n",(LPCSTR)pErr->NativeError);
AfxMessageBox(temp);
if ((LPCSTR)pErr->GetHelpFile() == NULL)
{
AfxMessageBox("\tNo Help file available\n");
}
else
{
CString temp1;
temp1.Format("\t(HelpFile: %s\n)" ,pErr->HelpFile);
AfxMessageBox(temp1);
temp1.Format("\t(HelpContext: %s\n)" , pErr->HelpContext);
AfxMessageBox(temp1);
}
}
}
catch(_com_error &e)
{
PrintComError(e);
}
}
void PrintComError(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
AfxMessageBox("Error\n");
CString temp;
temp.Format("\tCode = %08lx\n", e.Error());
AfxMessageBox(temp);
temp.Format("\tCode meaning = %s", e.ErrorMessage());
AfxMessageBox(temp);
temp.Format("\tSource = %s\n", (LPCSTR) bstrSource);
AfxMessageBox(temp);
temp.Format("\tDescription = %s\n", (LPCSTR) bstrDescription);
AfxMessageBox(temp);
}
|
|
|
|
|
Dear all,
I need to set quota limit for users on a shared folder on a file server.
How to implemented it in VC++? Is there a API function?
Thanks
|
|
|
|
|
Hi everyone,
I did not know where else to pose this question. So, here goes. If this is not the right place, please ignore it. Though, I would really appreciate some suggestions as to where to look.
I want to add an entry to the context menu of Windows explorer. Specifically, everytime someone right clicks on an XML file, I want to show a menu item which runs a python program. So I created the following registry entry file.
REGEDIT4
[HKEY_CLASSES_ROOT\.xml]
@="XMLfile"
[HKEY_CLASSES_ROOT\xmlfile]
@=""
[HKEY_CLASSES_ROOT\xmlfile\shell\Open with Something\command]
@="C:\\Python22\\wxPython\\tools\\boa\\boa.pyc"
This works fine, for any .EXE file. However, whenever I try to launch a python file, it does not work. It says [The XML file name] is not a valid Win32 document.
However, double clicking on boa.pyc runs it just fine. So, I do not know why it does not launch it.
Any suggestions or some registry scripts are welcome!
Pankaj
Without struggle, there is no progress
|
|
|
|
|
a .pyc file still runs through the python exe. try changing:-
[HKEY_CLASSES_ROOT\xmlfile\shell\Open with Something\command]
@="C:\PATH\TO\PYTHON\PYTHON.EXE C:\\Python22\\wxPython\\tools\\boa\\boa.pyc"
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
how can i put with Create function a working button on a Child Window of my mdi app derived from CFormView ?
<< Thank you people >>
|
|
|
|
|
Add a meber varibale of the control type to your form view class. Then call Create on it in the OnInitialUpdate() procedure. You will also need to position the control correctly on your formview using MoveWindow() etc. If you re-size your form in OnSize() check to make sure the actual windows exist before trying to move them around.
CButton m_MyButton ;
m_MyButton.Create("STOP!", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW | WS_TABSTOP | WS_CLIPSIBLINGS, CRect(0, 0, 10, 10), this, IDC_OF_YOUR_BUTTON) ;
m_MyButton.MoveWindow(...) ; // put button in correct place
Don;t forget to call m_MyButton.DestroyWindow() in the OnDestroy of your FormView.
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
how can i put with Create function a working button on a Child Window of my mdi app derived from CFormView ?
<< Thank you people >>
|
|
|
|
|
if you're using MFC it shouldn't be too difficult to call Create on a CButton object that you can allocate dynamically - haven't tried myself I have to say
|
|
|
|
|
I'm producing a Web Viewer so that our customers can view the Images that we scan for them from anywhere. They enter the site and perform a search for the images and then view them. Their search details are saved in the Web Server's Registry and the fields(text boxes) are populated with their last query the next time they enter the site. The site is writen using ASP, Javascript and an ISAPI extension dll, using MFC, that does all the database stuff and file handling etc.
However, although I can read their last query from the registry, I cannot set values. I am using CRegKey::Open, with the access set to KEY_SET_VALUE ( I have tried KEY_WRITE and KEY_ALL_ACCESS ).
The RegConnectRegistry( ) function before it is succeeding OK.
I have tried using GetLastError() and then FormatMessage to get the Error Message but it returns "The operation was successful"!
Oh, the OS is W2k.
Any help would be greatly appreciated.
code as below:
// open the Registry Key and update it...
// connect to the Registry...
if ( RegConnectRegistry( NULL, HKEY_LOCAL_MACHINE , &m_RegKey.m_hKey ) != ERROR_SUCCESS )
{
#ifdef _DEBUG
MessageBox( NULL,"Unable to connect to Registry", "ERROR !", MB_DEFAULT_DESKTOP_ONLY );
#endif
return;
}
// and open (or create and open) the key...
if( m_RegKey.Create( m_RegKey.m_hKey, m_strSubKey, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, NULL ) != ERROR_SUCCESS )
{
// if it fails, find out why...
int nGetLastError = GetLastError( );
#ifdef _DEBUG
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, nGetLastError, 0, (LPSTR)szBuffer, 255, NULL );
MessageBox( NULL, szBuffer, "ERROR - SetLastQueryData()", MB_DEFAULT_DESKTOP_ONLY );
#endif
return;
}
Thanx for your patience and any help,
code dope.
|
|
|
|
|
I think it's because your web-application is running under the same security context as your users. If those users are anonymous the process dont have rights to write to that part of the registry.
Why don't you just save the data in a database?
It sounds a lot of data to save in the registry...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
This is a typical case for using cookies.
|
|
|
|
|
Thanks Alex - I'll look into it, although I'm afraid my knowledge on Cookies is absolutely Zero (I'm just an ordinary ol' C, C++ programmer who's venturing into the Big and scary new world of Web Development!). Is it fairly easy?
Thanx again,
code dope.
|
|
|
|
|
My knowledge in cookies is exactly as yours. However, I know that they are done exactly for such purpose - to keep client settings on client computer. I would ask the separate question about cookies in message board.
|
|
|
|
|
Thanks, Anders, I think you're probably correct. However, unfortunately I am not permitted to create any new tables, views etc in the database.
The actual data is only about 10 words, so not really that much. Is there a way of changing the rights for an anonymous user without jeopardising the site, code, database etc.?
Thanx again,
code dope.
|
|
|
|
|
You _clould_ change the security settings in the registry, but that would open up a huge security hole
How about saving the data in a (XML)file instead?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
You definately want to use a Cookie, very simple in ASP. effin Simple.
I dont think a web application should ever store data in a registry entry.
Ryan Baillargeon
Software Specialist
Fuel Cell Technologies Inc.
|
|
|
|
|