|
Hy everyone!
I know it is possible to access any folder in Outlook via MAPI but I do want to check if the opend folder is lets say the Inbox folder.
Or is it possible to check if an item (e.g. a contact item) was selected?
Because I do want my button to be only selectable/clickable when one of those match. Meaning when any other folder is open then the button should appear grayed out.
Thanks!
Stephan.
|
|
|
|
|
I'm not sure what method of MAPI you are using but
Stephan Wright wrote:
I know it is possible to access any folder in Outlook via MAPI but I do want to check if the opend folder is lets say the Inbox folder.
This is stored in the PR_CONTAINER_CLASS property.
Stephan Wright wrote:
Or is it possible to check if an item (e.g. a contact item) was selected?
PR_MESSAGE_CLASS property identifies the type. A contact is IPM.Contact or occasionally IPM.Contact.SBE
Michael
CP Blog [^]
|
|
|
|
|
thanks for the hint but I do still have two questions:
1) Where is this PR_CONTAINER_CLASS located in? Because I can't find it
2) Together with this class: Is it possible to send the data to an application via argument that way or am I just able to check if it is this type. Or is it possible to assign it somewhere?
meaning is it something like
if(item.type==IPM.contact.SBE)
.....
or do I get access (a pointer?) to the object to use it for something else?
Thanks!
Stephan.
|
|
|
|
|
What method are you using to access the MAPI data?
I'm only familiar with using Extended MAPI via C++. PR_CONTAINER_CLASS is a property of the MapiFolder data. It isn't a class, its a defintion for the mapi property id.
Michael
CP Blog [^]
|
|
|
|
|
the way I get there is
new application of Outlook then namespace of MAPI
By the way: My programminglanguage is C# in Visual Studio, but well it should be all the same in Visual Studio!
Stephan.
|
|
|
|
|
Ok. You are using the Outlook object model. Sorry, for leading you down the wrong path.
If you have a MapiFolder object then you can use GetDefaultItemType() method to get the type of items in the folder.
I can't remember all the values but a google for Outlook GetDefaultItemType should return some more details.
Michael
CP Blog [^]
|
|
|
|
|
hi,
I'm developing a mediaplayer, and I need to disable the screensaver and the poweroff functions while playing a video file.
on msdn I found that I have to use the SystemParametersInfo[^] function.
This code works only partially: the screensaver is disabled, but the monitor is still switched off by the system.
[DllImport("user32.dll")]<br />
private static extern bool SystemParametersInfo<br />
(<br />
uint action,<br />
uint param,<br />
object data,<br />
uint winini<br />
);<br />
<br />
private const int SPI_SETSCREENSAVEACTIVE = 0x0011;
private const int SPI_SETPOWEROFFACTIVE = 0x0056;
<br />
private void someMethod()<br />
{<br />
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, null, 0); <br />
<br />
SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, null, 0);<br />
}
what's wrong?
thank you
________
http://www.jockersoft.altervista.org
|
|
|
|
|
|
Nope - if you read the documentation for SystemParametersInfo , it refers to the power phase of the screensaver.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The SPI_SETPOWEROFFACTIVE may have more to do with the system suspension state than the monitor. The documentation is a little vague on this matter.
I did try a few things. Handling the WM_POWERBROADCAST message with the PBT_APMQUERYSUSPEND only seems to work with the power state, so the next logical choice is something like this:
P/Invoke both GetActivePwrScheme and SetActivePwrScheme , as well as declare the POWER_SCHEME structure (you can flatten it if you like, since unmanaged structures are just blocks of contiguous memory). Information about these functions and this struct can be found in the Platform SDK at http://msdn.microsoft.com/library[^]. You can pass null (or IntPtr.Zero ) to the second parameter (declare it as an IntPtr in order to pass IntPtr.Zero ). If you do so, the signature would look like this:
[DllImport("powrprof.dll")]
static extern bool SetActivePwrSchema(uint id, IntPtr globalPolicy,
ref POWER_POLICY powerPolicy); First call GetActivePwrScheme to get an ID for the current policy. Change the POWER_POLICY.user.VideoTimeoutAc (typed as it's named in the Platform SDK) to either 0 or UInt32.MaxValue (not sure which) to set the power state of the monitor to off or a relatively indefinite time (far more than the life of a computer), whichever works (such values aren't documented).
Don't forget to clean-up your code, however, like storing the previous VideoTimeoutAc value and doing this over with the previous value. This will merge the previous state with the new state, but there's nothing I see in the documentation that dictates whether that merged state is persisted in the power scheme or if its just for the duration of the computer's up-time (still always a good idea to undo what you've done, though).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You might want to check out SetThreadExecutionState[^]. Calling this function with all three flags set will let the system know that your application needs the system to be completely powered up at all times.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thank you Heath and Dave for your hints.
I followed Dave's one (much simpler) and it works.
here is the code that does the job:
[DllImport("Kernel32.dll")]
private static extern uint SetThreadExecutionState
(
uint esFlags
);
private const uint ES_SYSTEM_REQUIRED = 0x00000001;
private const uint ES_DISPLAY_REQUIRED = 0x00000002;
private const uint ES_CONTINUOUS = 0x80000000;
private void disablePoweroff()
{
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
}
private void enablePoweroff()
{
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
}
thank you again,
bye
________
http://www.jockersoft.altervista.org
|
|
|
|
|
Hy everyone!
I implemented an addin in Outlook which calls an executable when the button in Outlook is clicked.
Well this isn't the problem. My problem is how to check, if there is already an instance of the programm, meaning avoiding the user to start it twice or more often e.g. displaying "application already running" or bringing the application to the foreground.
I tried to add a kind of counter in the method but it did not work.
My application is called via the Process.Start() command.
Thanks.
Stephan.
|
|
|
|
|
Stephan Wright wrote:
I tried to add a kind of counter in the method but it did not work.
By design it wont. No data is shared between application, unless u use remoting to connect to them.
Stephan Wright wrote:
My application is called via the Process.Start() command.
Give the process a name or some ID , and enumerate thru all the processes before starting yours.
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi stephan,
Firstly, i'm sure there is a better way of doing it than this but one of the programmes we use at work does it this way and it works for us, it creates a "Lock" file.
When the instance loads it first checks for this lock file, if it doesn't exist the program loads and creates the lock file, if the file already exists then an instance is already running so the program can just display an error and shut down.
When the instance finishes running just delete the lock file.
Like i said, not the best way of doing it and i'm sure someone will post the correct way to check but this is simple and as long as it's implimented correctly it will be effective.
Kev Pearman MCP
|
|
|
|
|
|
Using a mutex is more common to solve such a problem, as the next reply after yours recommended. Lock files can lead to problems, especially when they're not cleaned-up appropriately (i.e., the CLR crashes because of problems in the application).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is the app you are calling a C# app and you have the code,
If so, you could use a mutex to prevent a further instance of your app running.
See this article[^]
A google search for single instance mutex will return more results.
Michael
CP Blog [^]
|
|
|
|
|
thanks this solved my problem! Now it works!
Stephan.
|
|
|
|
|
Hi all,
I'd like to create a service running in the background on a client's computer to monitor various actions of the user, such as:
Logging URL's visited
Logging files downloaded etc ...
I was first going to use a Browser Helper Object to do this but then discovered that it would only work with Internet Explorer and not other browser types. I also discovered that a lot of marshalling would have to occur especially using the languange C#.
I would now like to code a firewall instead to log the various user actions. How would i go about doing this ? ... Any code or reference sites would be much appreciated.
Thank you for your time
|
|
|
|
|
|
I'm currently a student thats studying and i have to create this application as a 4th year project, so i have to physically code a application.
Any help will be very much appreciated ...
|
|
|
|
|
Then code a log analyzer. .NET is too high-level, as I said in my email, for such a task. Software firewalls must be integrated at a very low level with Windows, something that C/C++ is more suited for. A firewall must be very efficient and must hook the internet connections in Windows, which also works differently on different Windows platforms.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Even writing the firewall will require a ton of marshalling and P/Invoking...
C# and VB.NET are too high a level for the projects your coming up with. A firewall app would be better written in C++. Maybe not the entire app, but the filtering engine would definately be C++, maybe even Managed C++. You could write management interface for the engine in C# though.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Gurus!
I created a web application in C# but when I created a new Setup project and add all files and outputs I desired I got a wariing massage when I selecting Build->Batch build->Rebuild all. The warning messge is
"Unable to build folder named Admin"
So does any of you knows what's happening? Please give some solution to build my setup project...
Thanx.
xedom developers team
|
|
|
|