Tuesday, December 21, 2010

VBS获取屏幕分辨率

用VBS获取屏幕分辨率
我想到的方法有两种。
一种是WMI中的Win32_DesktopMonitor类
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48)

For Each objItem in colItems
 WScript.Echo "ScreenHeight: " & objItem.ScreenHeight
 WScript.Echo "ScreenWidth: " & objItem.ScreenWidth
Next

一种是HTML DOM中的screen对象
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "about:blank"
Set screen = IE.Document.parentWindow.screen
WScript.Echo "ScreenHeight: " & screen.height
WScript.Echo "ScreenWidth: " & screen.width

参考链接
1. Win32_DesktopMonitor Class
2. screen Object

测试syntax Highlighting:我的曲线打断

#include "StdAfx.h"
#include "resource.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("")

void drawEntity(AcDbEntity* pEntity);
bool breakCurve(AcDbCurve* curve,AcGePoint3d pt);
bool breakCurve(AcDbCurve* curve, AcGePoint3d p1, AcGePoint3d p2);

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CMybreak2008App : public AcRxArxApp {

public:
 CMybreak2008App () : AcRxArxApp () {}

 virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
  // TODO: Load dependencies here

  // You *must* call On_kInitAppMsg here
  AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
  
  // TODO: Add your initialization code here

  return (retCode) ;
 }

 virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
  // TODO: Add your code here

  // You *must* call On_kUnloadAppMsg here
  AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;

  // TODO: Unload dependencies here

  return (retCode) ;
 }

 virtual void RegisterServerComponents () {
 }

public:

 // - Mybreak2008._Mybreak command (do not rename)
 static void Mybreak2008_Mybreak(void)
 {
  // Add your code for command Mybreak2008._Mybreak here
  ads_point pt1,pt2;
  ads_name entName;
  Acad::ErrorStatus es;
  int ret;
  ACHAR kWord[100];
    
  if (acedEntSel(_T("\n选择所要打断的曲线:"), entName, pt1) !=RTNORM)
  {
   return;
  }
  AcDbObjectId entId;
  AcDbCurve *pCurve=NULL;
  AcDbEntity *pEnt = NULL;
  es = acdbGetObjectId(entId, entName);
  if (es != Acad::eOk)
  {
   return;
  }
  acdbOpenObject(pEnt, entId, AcDb::kForWrite);

  if (pEnt->isKindOf(AcDbCurve::desc()))
  {
   pCurve = AcDbCurve::cast(pEnt);
   if (pCurve != NULL)
   {
    acedInitGet (NULL, _T("F"));
    ret=acedGetPoint(NULL,_T("\n指定第二个打断点或[第一点(F)]:"),pt2);
    switch (ret)
    {
     case RTKWORD:
      ret=acedGetInput(kWord);
      if ( ret!= RTNORM )
       break ;

      acedInitGet(RSG_NONULL, _T(""));
      ret=acedGetPoint(NULL,_T("\n指定第一个打断点:"),pt1);
      if (ret!=RTNORM)
       break;

            acedInitGet(RSG_NONULL, _T(""));
      ret=acedGetPoint(NULL,_T("\n指定第二个打断点:"),pt2);
      if (ret!=RTNORM)
       break;

      breakCurve(pCurve,asPnt3d(pt1), asPnt3d(pt2));
      break;
     case RTNONE:
      breakCurve(pCurve,asPnt3d(pt1));
     case RTNORM:
      breakCurve(pCurve,asPnt3d(pt1), asPnt3d(pt2));
      break;
     default:
      break;
    }
   }
  }
  pEnt->close();
 }
} ;

//以下为函数
//打断于点
bool breakCurve(AcDbCurve* curve,AcGePoint3d pt)
{
 AcGePoint3d p1;
 curve->getClosestPointTo(pt,p1);
 double param;
 curve->getParamAtPoint(p1,param);
 AcGeDoubleArray params;
 params.append(param);

 AcDbVoidPtrArray curveSegments;
 curve->getSplitCurves(params, curveSegments);
 AcDbEntity* pEnt =NULL;
 if (curveSegments.length()==2)
 {
  pEnt=(AcDbEntity*)curveSegments[0];
  drawEntity(pEnt);
  pEnt->close();
  pEnt=(AcDbEntity*)curveSegments[1];
  drawEntity(pEnt);
  pEnt->close();
  curve->erase();
 }
 else
 {
  curve->close();
 }
 return true ;
}
//两点打断
bool breakCurve(AcDbCurve* curve, AcGePoint3d p1, AcGePoint3d p2)
{
 AcGePoint3d p11;
 curve->getClosestPointTo(p1,p11);
 double param1;
 curve->getParamAtPoint(p11,param1);
 AcGePoint3d p21;
 curve->getClosestPointTo(p2,p21);
 double param2;
 curve->getParamAtPoint(p21,param2);
 AcGeDoubleArray params;
 if (param1getSplitCurves(params, curveSegments);
 AcDbEntity* pEnt =NULL;
 if (curveSegments.length()==2)
 {
  pEnt=(AcDbEntity*)curveSegments[1];
  drawEntity(pEnt);
  pEnt->close();
 }
 else if (curveSegments.length()==3)
 {
  pEnt=(AcDbEntity*)curveSegments[0];
  drawEntity(pEnt);
  pEnt->close();
  pEnt=(AcDbEntity*)curveSegments[2];
  drawEntity(pEnt);
  pEnt->close();
 }
 curve->erase();
 return true ;
}
//绘制打断的曲线
void drawEntity(AcDbEntity* pEntity)
{ 
 AcDbBlockTable *pBlockTable;
 acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);
 AcDbBlockTableRecord *brec;

 resbuf tilemode;
 acedGetVar(_T("TILEMODE"),&tilemode);
 int tile=tilemode.resval.rint;
 if (tile)
  pBlockTable->getAt(ACDB_MODEL_SPACE, brec,AcDb::kForWrite);
 else
  pBlockTable->getAt(ACDB_PAPER_SPACE, brec,AcDb::kForWrite);
 pBlockTable->close();
 AcDbObjectId entid;
 brec->appendAcDbEntity(entid, pEntity);
 brec->close();     
}

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CMybreak2008App)

ACED_ARXCOMMAND_ENTRY_AUTO(CMybreak2008App, Mybreak2008, _Mybreak, Mybreak, ACRX_CMD_TRANSPARENT, NULL)

博客被墙了之后。。。

今天找到了一个好的办法应付博客被墙了之后不能更新。
那就是用软件GapProxy