In my MFC application I have set the read only attribute on a particular file.
I have done this by using the SetFileAttributes() function.
At some point I have to remove that attribute of that file again.
Can anyone explain how to do this?
Use SetFileAttributes again to reset the flag:
SetFileAttributes( pszFilename,
GetFileAttributes(pszFilename) & ~FILE_ATTRIBUTE_READONLY);
Might be worth adding that this method returns 0 if the function fails and you can use GetLastError().
Related
I want to set the CalendarDetail property of CalendarSharing object.
Found the below link where we can set it using Outlook Object Model - https://learn.microsoft.com/en-us/office/vba/api/outlook.calendarsharing
I have written the below code in my C++ add-in. Where can not see the method GetCalendarExporter(), its missing :( I am calling it on Olk::MAPIFolderPtr.
What is wrong here? How to set the above property?
CComPtr<Olk::_NameSpace> spNameSpace;
GetMapiNameSpace((LPVOID *)&spNameSpace);
Olk::MAPIFolderPtr calendarFolder = spNameSpace->GetDefaultFolder(Olk::OlDefaultFolders::olFolderCalendar);
calendarFolder->GetCalendarExporter() **// Not able to see this method**
That means you have old headers. Recreate the Outlook Object Model tlh file.
I'm trying to implement an icon-based property in Windows File Explorer, and my understanding from this post is that it requires returning a property store binary file from the property handler. Does anyone know how to create a property store binary file? After searching, I've come across some documentation on the specification, but I don't see any examples of how to create one. Thank you very much.
You don't need any binary file, you just need an implementation of IPropertyStore. You can create one using the PSCreateMemoryPropertyStore method.
IPropertyStore *ps;
if (SUCCEEDED(PSCreateMemoryPropertyStore(IID_PPV_ARGS(&ps))))
{
// do your work
ps->Release();
}
I want to prevent IE from showing JS error dialogs, I read that it can be done by setting
ScriptErrorsSuppressed = true.
Where exactly do I set it in IWebBrowser2?
Thanks
Simply use put_Silent method.
m_pWebBrowser->put_Silent(VARIANT_TRUE);
As mentioned earlier, use the put_Silent() method to turn error reporting on or off.
For example, if using a CDHtmlDialog, put this in your OnInitDialog():
m_pBrowserApp->put_Silent(VARIANT_TRUE);
and put it before the LoadFromResource() call.
Be careful though as this will suppress a lot more messages than just JavaScript errors. (Think SSL certificate notifications.)
make change in both HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE paths.
Software\\Microsoft\\Internet Explorer\\Main
RegSetValueEx (hKey, LPCSTR("Disable Script Debugger"), 0, REG_SZ, (BYTE*) "yes", 3);
RegSetValueEx (hKey, LPCSTR("DisableScriptDebuggerIE"), 0, REG_SZ, (BYTE*) "yes", 3);
The docs you are reading refer to what you can do if you embed an IE HTML rendering pane in your own application. They allow you to alter the behavior of that pane.
If you have done that, then you can use COM to QueryInterface an IWebBrowser2 interface from the component.
See more here:
http://support.microsoft.com/kb/196340
And here's how you handle errors:
http://support.microsoft.com/kb/261003
I suspect that that's not what you are trying to do, and that you are just making a web-app. In that case, you need to
Fix your JS errors
Put all of your JS code in try/catch blocks. Then you won't get JS dialogs, but you need to handle the error yourself.
The quick and easy way would be to use a global state to solve a local problem and modify the registry as described here (although Raymond would disapprove of doing so). This basically deactivates script errors entirely for the currently logged in user.
Summary:
Registry Key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
Value Name: Disable Script Debugger
Data Type: REG_SZ (String Value)
Value Data: yes
The more complex solution would be implementing IOleCommandTarget, as already pointed out by Lou.
I have set a file to be read-only (right click and check readonly). Now when I try to remove the file using the function bool QDir::remove(const QString & fileName) the file is not removed and false is returned.
How do I proceed with this? I have tried fiddling around by changing the permission of the file using QFile::setPermission, but that returns false too.
Can anybody advise an approach for the same?
file.setPermissions(QFile::ReadOther | QFile::WriteOther);
file.remove();
should work.
You can set file permissions with QFile
Of course this only for files you have user permission to do. The error may also be because the file is open in another app
First, have you checked QFile::error() to see why the file wasn't removed?
Second, in the event that you're still not getting a useful error message back, you could check the source to find out if you can get more information. Checking the source reveals the following, for example:
QFile::remove() uses the underlying file engine to do the removal. That file engine is platform specific and in qfsfileengine_win.cpp for windows. Line 830 shows that it's using DeleteFile to do the removal so you might be able to get more information by calling GetLastError, though I'd hope that Qt translates the error message appropriately.
QDir::remove() function is not a static function. so you can create QDir with parent file path and call then remove it:
QDir dir(parent's directory);
and then
dir.remove(fileName);
I think you should use this:
bool QFile::remove ( const QString & fileName ) [static]
instead of this:
QDir::remove ( const QString & fileName )
Have you tried to use bool QFile::remove(const QString &fileName)?
I try use the "GetModuleFileName" to get current "setup.msi" location use mydll.dll in setup.msi installer.
But always give me "c:\windows\system\setup.msi".
Any body know why ? Plx help .
You mention C++ so I'm assuming that you are creating a Type 1 custom action as described here. If this is so, I'm guessing that you are trying to figure out where the install is occurring from so you can reference a file or something. If so, check out the MsiGetProperty function and the OriginalDatabase property. If that doesn't meet your needs checkout the the MsiSourceList* functions starting with MsiSourceListGetInfo.