2008年1月23日 星期三

[DirectShow + Java] 自動註冊一堆 Filters

每次看到一些程式安裝時, 註冊一堆東西到我的電腦, 如果你開發的是 DirectShow 程式, 這個批次註冊程式的技巧, 你應該要學會!

In several multimedia applications, automatically registry a set of filters is needed.

How to do this?

Following codes is an example.

 

boolean bSlienceMode=true;
System.out.print("\nRegistry the codec ...");
Runtime rn=Runtime.getRuntime();

Process p;

if(bSlienceMode){

     // 注意: 這裡 s 後面要空格, 否則程式將會靜靜的不給你註冊
      p=rn.exec("regsvr32.exe /s "+strFullCodecFilename); // slience
}
else{
     p=rn.exec("regsvr32.exe "+strFullCodecFilename);
}
p.waitFor(); // wait for the command finish
System.out.println(" .......... ok.");

 

by Jing

by Jing

沒有留言:

張貼留言