English 中文(简体)
如何从使用 asp 的设备中 WincE 5. 0 OS 读取. ini 文件?
原标题:How to read .ini files from WinCE 5.0 OS in a device using asp

我需要通过 ASP 读取 WincE 5. 0 设备文件系统中的. ini 文件。 下面是读文件的脚本 。 < streng > 但设备无法创建“ scripting. FileSystemObject” 类型的 AFentX 对象

- - - - - - - - - - - - - - - - - - - - - - - -

<%
function GetINIString(Section, KeyName, Default, FileName)
{
  var INIContents, PosSection, PosEndSection, sContents, Value, Found;

  //Get contents of the INI file As a string;
  INIContents = GetFile(FileName)

  //Find section;
  PosSection = InStr(1, INIContents, "[" + Section + "]", 1);
  if(PosSection>0)
  {
    //Section exists. Find end of section;
    PosEndSection = InStr(PosSection, INIContents,  
  + "[");
    //?Is this last section?;
    if(PosEndSection == 0)
    { 
        PosEndSection = Len(INIContents)+1;
        //Separate section contents;
        sContents = Mid(INIContents, PosSection, PosEndSection - PosSection)
        if (InStr(1, sContents,  
  + KeyName + "=", 1) > 0) 
        {
            Found = True;
            //Separate value of a key.;
            Value = SeparateField(sContents,  
  + KeyName + "=",  
 );
        }
    }
  }
  if(isempty(Found))
  { 
    Value = Default;
  }
  return Value;
}

//Separates one field between sStart && sEnd

function SeparateField(sFrom,sStart,sEnd)
{
  var PosB;
  PosB = InStr(1, sFrom, sStart, 1);
  if(PosB > 0)
  {
    PosB = PosB + Len(sStart);
    var PosE;
    PosE = InStr(PosB, sFrom, sEnd, 1);
    if(PosE == 0)
    { 
        PosE = InStr(PosB, sFrom,  
 , 1);
    }
    if (PosE == 0) 
    {
        PosE = Len(sFrom) + 1;
    }
    SeparateField = Mid(sFrom, PosB, PosE - PosB);
  }
}


//File functions

function GetFile(FileName){
  var FS;
  FS = new ActiveXObject("Scripting.FileSystemObject");
  //Go To windows folder if(full path ! specified
  if(InStr(FileName, "%3A%5C") = 0 && Left (FileName,2)!="\")
  { 
    FileName = FS.GetSpecialFolder(0) + "1" + FileName;
  }
  //On Error Resume Next

  return FS.OpenTextFile(FileName).ReadAll;
}

function WriteFile(FileName,Contents)
{
  var FS;
  FS = new ActiveXObject("Scripting.FileSystemObject");
      //On Error Resume Next

      //Go To windows folder if(full path ! specified
      if(InStr(FileName, "%3A%5C") == 0 && Left (FileName,2)!=="/")
      {
        FileName = FS.GetSpecialFolder(0) + "1" + FileName;
      }

  var OutStream;
  OutStream = FS.OpenTextFile(FileName, 2, True);  
}
function GetINIStringVirtual(Section, KeyName, Default, FileName)
{
  return GetINIString(Section, KeyName, Default,  Server.MapPath(FileName));
}
%>
问题回答

FSO (FileSystemObject) 不存在于 Windows CE 中

因此,在中欧共同体中,必须:

FS = new ActiveXObject("FILECTL.FileSystem");

UPDATE 文件引用为: MSCEFile.dll

我不确定这是否在 WincE 5 到期日的操作系统是旧的操作系统

documentation < a href=>"http://support.automation.siemens.com/WW/lisapi.dll?func=cslib.csinfo&lang=en&objid=13408815%20&caller=view"rel="nofollow" >FSO Windows和 WincE之间的差异





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签