Boot Windows adding a local drive pointing to SHarepoint Online Folder



Announcing Dev10 Beta 2


 

Visdual Studio 2010 Beta is now available here.

Please start pounding it on it and let us know what you think.


Dynamically add commands to your VSIP Package


The set of commands that you can expose in a Visual Studio Package is fixed and defined by the .ctc file that you compile and include into your satellite dll.

But what if after installation you need to create more commands? There is a solution to this problem. It implies having the ctc.exe (Command table compiler) from the VSIP distribution bits be distributed with your VSIP package. But that's the only piece of bits that you will need from the VSIP distribution.

Let's begin, at runtime your package will need to create a new CTC file and have the CTC.EXE (the ctc compiler tool) compile it into a cto file.

Notice that you are creating a dependency to the VSIP bits by having to invoke ctc.exe. However, with a little extra effort that will be the only dependency to the VSIP bits.

Normally a CTC file uses the command preprocessor from Visual C++ compiler: cl.exe. You don't want to include the C++ compiler with your VSIP package right? Well the trick is to fool the ctc compiler with a dummy command preprocessor. This small batch script will be enough:

@echo off

echo #line 1 %4

type %4

Because we are not using the real preprocessor, then our generated CTC file cannot use any symbols that are defined in another inclusion file. For example, you cannot use the header file "vsshlids.h", instead you need to generate your CTC file without the help of any macro replacement.

For example, instead of using replacement macros like in here:

CMDS_SECTION MyPackageGUID

MENUS_BEGIN

MENUS_END

NEWGROUPS_BEGIN

MyGroupGuid:0x0100, guidSHLMainMenu:IDM_VS_MENU_TOOLS,0x600;

NEWGROUPS_END

BUTTONS_BEGIN

MyGroupGuid:0x0100,MyGroupGuid:0x0100,0x0400, OI_NOID,0x00000001,0x00000000,"&My New Command";

BUTTONS_END

BITMAPS_BEGIN

BITMAPS_END

CMDS_END

CMDUSED_SECTION

CMDUSED_END

CMDPLACEMENT_SECTION

CMDPLACEMENT_END

VISIBILITY_SECTION

VISIBILITY_END

KEYBINDINGS_SECTION

KEYBINDINGS_END

You will have to use the real value and generate this:

CMDS_SECTION { 0x77D93A80, 0x73FC, 0x40F8, { 0x87, 0xDB, 0xAC, 0xD3, 0x48, 0x29, 0x64, 0xB2 } }

MENUS_BEGIN

MENUS_END

NEWGROUPS_BEGIN

{ 0x96119584, 0x8C4B, 0x4910, { 0x92, 0x11, 0x71, 0xD4, 0x8F, 0xA5, 0x9F, 0xAF } }:0x0100, { 0xD309F791, 0x903F, 0x11D0, { 0x9E, 0xFC, 0x00, 0xA0, 0xC9, 0x11, 0x00, 0x4F } }:0x0413,0x600;

NEWGROUPS_END

BUTTONS_BEGIN

{ 0x96119584, 0x8C4B, 0x4910, { 0x92, 0x11, 0x71, 0xD4, 0x8F, 0xA5, 0x9F, 0xAF } }:0x0100,{ 0x96119584, 0x8C4B, 0x4910, { 0x92, 0x11, 0x71, 0xD4, 0x8F, 0xA5, 0x9F, 0xAF } }:0x0100,0x0400,{ 0xD309F794, 0x903F, 0x11D0, { 0x9E, 0xFC, 0x00, 0xA0, 0xC9, 0x11, 0x00, 0x4F } }:0x02EA,0x00000001,0x00000000,"&My New Command";

BUTTONS_END

BITMAPS_BEGIN

BITMAPS_END

CMDS_END

CMDUSED_SECTION

CMDUSED_END

CMDPLACEMENT_SECTION

CMDPLACEMENT_END

VISIBILITY_SECTION

VISIBILITY_END

KEYBINDINGS_SECTION

KEYBINDINGS_END

Yes, I know it looks ugly (actually both files look really ugly), but it will be auto generated. Notice that the guid of the CMDS_SECTION must match the guid of your VSIP package. This is a very important detail; the guid must match so that VS finds a loaded package with that guid.

Now you are ready to invoke ctc and create your own cto file, you will invoke like this:

ctc.exe MyCTCFile.ctc MyCTCFile.cto –Ccpp.bat

where MyCTCFile.ctc if your generated ctc file and cpp.bat is the dummy preprocessor.

Ok, now you have a cto file, but how do make VS load it? The answer: 1. by creating a new satellite dll and 2. Registering it as the satellite dll of a non existent or dummy package.

1. To create a new satellite dll, you can use the exiting satellite dll from your VSIP Package (If you package does not have a satellite dll, you will have to create an empty one).

Then you can use the BeginUpdateResource and UpdateResource functions to create you new satellite dll from the original satellite dll.

internal sealed class NativeMethods

{

[DllImport("kernel32.dll", SetLastError = true)]

public static extern IntPtr BeginUpdateResource(string pFileName, Int32 bDeleteExistingResources);

[DllImport("kernel32.dll", SetLastError = true)]

public static extern Int32 EndUpdateResource(IntPtr hUpdate, Int32 fDiscard);

[DllImport("kernel32.dll", SetLastError = true)]

public static extern Int32 UpdateResource(IntPtr hUpdate, string lpType, Int16 lpName, Int16 wLanguage, byte[] lpData, Int32 cbData);

}

File.Copy("OrginalSatellite.dll", SatelliteDllFileName);

IntPtr hUpdate = IntPtr.Zero;

using (FileStream ctoFile = new FileStream(tempCTO, FileMode.Open,FileAccess.Read))

{

using (BinaryReader ctoData = new BinaryReader(ctoFile))

{

byte[] ctoArray = ctoData.ReadBytes((int)ctoFile.Length);

hUpdate = NativeMethods.BeginUpdateResource(this.SatelliteDllFileName, 1);

try

{

if (hUpdate.Equals(IntPtr.Zero))

{

Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());

}

if (NativeMethods.UpdateResource(

hUpdate, "CTMENU", (Int16)ResourceId,

(short)CultureInfo.CurrentUICulture.LCID,

ctoArray, (Int32)ctoArray.Length) != 1)

{

Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());

}

}

finally

{

if (!hUpdate.Equals(IntPtr.Zero))

{

NativeMethods.EndUpdateResource(hUpdate, 0);

hUpdate = IntPtr.Zero;

}

}

}

}

In this code, the string "OrginalSatellite.dll" represents the location of the satellite dll of your package. The variable tempCTO is the file name of cto file created by the invocation of ctc.exe.

2. Ok, you got a new satellite dll, but as I said before, we need a dummy package for this new satellite dll. Basically you will need to create a new guid, this new guid can be stolen from a guid used in the generated ctc file, I am creating a new command group in my ctc file, so I am using the same guid for the dummy package.

Register the dummy package by creating a new key under HKLM\Software\Microsoft\VisualStudio\Packages:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\{96119584-8C4B-4910-0x9211-71D48FA59FAF}]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\{96119584-8C4B-4910-0x9211-71D48FA59FAF}\SatelliteDll]

"DllName"="MyNewSatelliteDllName.dll"

"Path"="C:\\Path\\To\\My\\New\\SatelliteDll"

As with any other satellite with menu resources we need to register it in the HKLM\Software\Microsoft\VisualStudio\\Menus

Just write a new string entry with the dummy package guid and the value as ",ResourceId,1", where ResourceId must match the id that you use in the call to UpdateResource:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Menus]

"{96119584-8C4B-4910-0x9211-71D48FA59FAF}"=",101,1"

Now you must exit devenv.exe and run devenv.exe /setup again so that VS rebuild the command table.

That's it. Your VSIP package has now more commands attach to it.

Improvements:

- Remove the dependency to the ctc.exe file, this will require knowledge on the binary representation of a cto file. I suspect that the format is not complicated and very straight forward.

- This procedure requires you to run devenv.exe /setup, is there a way to update the command table of VS at runtime?


Going to TechEd


I'll be in TechEd at the Visual Studio Team Architect demo station.

See you there.


How to: Display modeling diagrams outside Visual Studio


 

 

In one of Cameron's blog post we show how to load and save a diagram from within Visual Studio. In this post we'll show how to use the modeling API to load an Uml diagram outside Visual Studio from a small Windows Form Application and display the diagrams in it.

The modeling API uses the interface IModelingProjectReader to access data in the modeling project.

In order to use this API you need to add the following references to your project:

Microsoft.VisualStudio.ArchitectureTools.Extensibility

Microsoft.VisualStudio.Uml.Interfaces

 

To load a modeling project use the following code:

using Microsoft.VisualStudio.ArchitectureTools.Extensibility;

using Microsoft.VisualStudio.ArchitectureTools.Extensibility.Presentation;

 

this.modelingProject = ModelingProject.LoadReadOnly(openFileDialog.FileName);

 

Once the project is loaded, we need to get the list of diagrams in that project:

foreach(var diagramFile in this.modelingProject.DiagramFileNames)

{

  ShowDiagram(this.modelingProject.LoadDiagram(diagramFile));

}

 

Now we are almost ready to get the diagram, but first we need to add the following reference to our project:

Microsoft.VisualStudio.Modeling.Sdk.10.0

Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0

 

LoadDiagram from IModelingProjectReader will return an IDiagram instance, from this instance you need to get the shape element for the DSL diagram. To do this use GetObject:

using Microsoft.VisualStudio.ArchitectureTools.Extensibility.Presentation;

using DslDiagrams = Microsoft.VisualStudio.Modeling.Diagrams;

 

void ShowDiagram (IDiagram diagram)

{

  var dslDiagram = diagram.GetObject<DslDiagrams::Diagram>();

 

Once we have the dslDiagram we can use the CreateMetafile from the DSL API to get the image out of the diagram:

var selectedShapes = new []

  { diagram.GetObject<DslDiagrams::PresentationElement>() }.ToList();

var image = dslDiagram.CreateMetafile(selectedShapes);

 

 

That's it. I zip the sample at WinFormsViewer.zip, the sample code has a modeling project, and this is how the viewer looks like:

 

 

Hope you find this useful.


How to enable TV ratings under parental controls in MCE


If you don't have TV Ratings under your parental settings in Windows Media Center, most likely is because the COM object that implements that functionality is not installed with your TV turner driver, in the case of Hauppauge, if you install the WHQL driver then you will loose TV Ratings, if you install the retail driver you will get TV Ratings. The reason is that the retail driver includes the file hcwxds.dll.

For NVIDIA, that dll is NVTVRAT.DLL and for Emuzed it is EZRATING.DLL

Regards,

Oscar Calvo


How to: Run Expression Encoder 3 under PowerShell remoting


James wanned me to explain the set of steps I use to enable Convert-Media under a PowerShell remoting.

First a disclaimer: running these steps will lower the security settings of your PC, use with caution.

Here there are:

In your encoding server (mine is called tv-server):

Enable-PSRemoting -force # Enables remoting
set-item WSMan:\localhost\Client\TrustedHosts * -force # I am not running a domain controller, so my server needs to trust everybody
set-item wsman:localhost\Shell\MaxMemoryPerShellMB 1024 -force # The default allowed memory is very low, we need to bump it so that Convert-Media have room to work.
Enable-WSManCredSSP -Role Server -force # I need the server to have access to my Windows Home Server, so it needs to autenticate using credential delegation

In your client:

function AllowDelegation($policyName)
{
$keyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\"+$policyName
if (test-path $keyPath)
{
rmdir $keyPath -force -rec
}
$key = mkdir $keyPath
$key.SetValue("1","WSMAN/*");
}
AllowDelegation "AllowDefaultCredentials"

AllowDelegation "AllowFreshCredentials"

Enable-WSManCredSSP -Role Client -DelegateComputer * -force

In order to remote into your server do:

Enter-PSsession <ServerName> –cred <UserName>

I have used "*" (star) in two places, that's too broad, if you are already using a DNS suffix I would recommend to use it and change "*" to "*.mydomain.com".

In that case you need to refer to your server as:

Enter-PSsession <ServerName>.mydomain.com –cred <UserName>

Once inside, load the Encoder module as usual and execute Convert-Media.

You could Batch background encoding jobs using the instructions from the PowerShell team.

Enjoy,


Intro


Hello, after working with DevDiv and p&p as vendor for the past 7 years (wow, I can't believe it's so long) I finally joined Microsoft as a full time employee. I joined the VS Team Architect team as an SDE 2 months ago. I joined the team just in time for the Visual Studio 2008 release, I am really excited of the features that my team is delivering but more so about the ones in the future.

Joining Microsoft has been a huge change for me, both professionally and personally (I relocated from Costa Rica) and it's been an incredible busy year, so forgive me if I haven't answer your CAB and/or GAT questions (I know there are a couple here and there). Meanwhile I move the CAB and GAT articles from my previous employer web site to the msdn blog site.

Regards,

Oscar Calvo