Tuesday, October 7, 2008

Installing Windows XP from USB

Installing Windows XP from USB

I wrote this piece back in March 2006 before transferring it to my new blog. It’s quite possible that bits and pieces of this HOWTO are outdated. If any are and you find a solution, then please leave a comment for everyone to peruse.

What follows is a recipe on how to install Windows XP from USB. You can cut right to the case or read about how it happened to me, first. Sit tight, you’re in for a ride!

Case In Point

You’ve got this Acer laptop with a malfunctioning DVD drive. Specifically, you removed it from its bay and now Windows XP crashes when you plug it back in. Knowledge Base article 310664 matches it to a tee.

Provided solution: update to Service Pack 1, or disable DMA in the BIOS. Current situation: running SP2 and blessed with a “user-friendly” BIOS that doesn’t allow you to disable DMA.

Your luck just ran out, but - being the geek that you are - you don’t whine about it. Instead, you come up with this bright idea: let’s install Linux, that’ll work some magic! And so you get Gentoo Linux installed using a home-brewn LiveUSB distribution. And much to your dismay, proper hotplugging implementation for your laptop is lacking. Curses.

So finally, you call the support line to have them collect your laptop for repair. One problem here: you’re betting they won’t like seeing Linux boot up and, hoping to forego additional service costs, it’s up to you to reinstall Windows XP.

One problem here: you don’t have a working CD-ROM drive to install Windows XP off, and from experience you know that Windows XP won’t install from an external drive. Blasted!

Enter the cavalry.

Disclaimer

The procedure here is provided without any warranty or support whatsoever. It worked for me and so it might for you. It also might blast you and your laptop to pieces. Some of the procedures described here can wipe all of your data. Thought I’d warn you.

I don’t mean to be inventive here, either. In fact, all the technology has been laid out for us and is readily available. All I’m doing is wrapping it all up in writing. Shouts out to everyone who provided the technology!

That being said, let’s get down to business.

Ground Zero: Ingredients

You’ll be needing ample space on a USB storage device like a thumbdrive or external disk drive. 1 GB of storage will suffice. Possibly, you could access the setup files from a network share in which case you’ll only need a 256 MB thumbdrive, but I haven’t tried that.

Personally, I booted off a 512 MB thumbdrive and put the Windows XP setup files on an external disk drive. So a combination will do just fine, but just make sure that you’ve got sufficient USB ports: all USB devices will need to be plugged in and stay plugged in while we’re booted into BartPE later on!

You’ll also need a bunch of software, including a valid copy of Windows XP. The other software components can be downloaded freely:

Q: Why Windows 2003 Server Service Pack 1? I want to install XP!

A: Well that’s exactly the trick, though it’s a bit technical. During booting, Windows resets the USB port and loses your boot device. That’s why an installation from USB normally fails. But by using Windows 2003 Server’s ramdisk feature in the early phases of booting, we circumvent that problem.

Don’t be mislead though: you’ll be installing Windows XP all the same. It’s just that we’ll be using two Windows 2003 Server files from the Service Pack to do it.

You can also perform a Windows 2003 Server installation using this exact same procedure, save that you’ll be needing to update to Windows 2003 Server Service Pack 1 instead of Windows XP SP2, below. That’s assuming, of course, that you’ve got a valid copy of Windows 2003 Server.

You will also need an already functional Windows system to prep the USB disk from. In addition, your target system (the one that needs reinstalling) should support booting from USB. Virtually all modern ones do though.

Finally, not all cheaper USB devices properly support being booted from. The BartPE forums have a partial list of ones that don’t.

Step One: Preparing the Windows XP Setup Files

For this procedure to work correctly, you’ll need Windows XP to be at Service Pack 1 or Service Pack 2. Many newer Windows XP CDs already have either one included.

You can check by inserting the CD-ROM and looking at the files in the top folder. There should be a file named WIN51P.SP1 or WIN51P.SP2. If you see either one, fast forward to step two.If there is no such file, or you’ve got a SP1 CD that you would like to update to SP2, proceed as follows:

  1. Copy the Windows XP CD-ROM to a location on your hard drive. We’ll be assuming C:\winxpcd. I strongly advise you to use such a vanilla CD. Users have reported strange happenings with custom XP distributions.
  2. Download the Windows XP Service Pack 2 Network Installation Package.
  3. Unpack Windows XP SP2 by running WindowsXP-KB835935-SP2-ENU.exe -x. Note the -x parameter that will allow you to specify a location to unpack to. We’ll be assuming C:\winxpsp2.
  4. Integrate SP2 into the setup files by running C:\winxpsp2\i386\update\update.exe /integrate:c:\winxpcd.

If your system needs special drivers to operate, this would be the time to include them (called “slipstreaming”). Doing so isn’t exactly trivial and should only be necessary if you, say, require non-standard SATA support. The process is beyond the scope of this article, but fortunately Google is your friend.

Step Two: Prepping BartPE

First we’ll prep the USB drive we’ll be using for booting. This is by far the largest step in the process, though it shouldn’t be difficult for anyone to follow. It requires a functional Windows system.

  1. Install BartPE. We’ll be assuming that you install to C:\pebuilder.
  2. Unpack PE2USB to C:\pebuilder.
  3. Unpack Windows 2003 SP1 by running WindowsServer2003-KB889101-SP1-x86-ENU.exe -x (that’s assuming that you downloaded the English version). Note the -x parameter that will allow you to specify a location to unpack to. We’ll be assuming C:\server2003sp1.
  4. Create a folder named C:\pebuilder\srsp1.
  5. Copy C:\server2003sp1\i386\setupldr.bin to C:\pebuilder\srsp1.
  6. Expand and copy ramdisk.sys by running expand -r C:\server2003sp1\i386\ramdisk.sy_ C:\pebuilder\srsp1.
  7. Start PE Builder from the Start Menu. Point “Source:” to the location of your Windows XP setup files containing SP1 or SP2.
  8. Make sure the “Output:” is set to “BartPE”. If using SP2: go into the Plugins configuration dialog and enable “RpcSS needs to launch DComLaunch Service First - SP2 only”.
  9. Hit “Build”.
  10. When it’s done building, insert the USB drive you intend to boot from and run C:\pebuilder\pe2usb -f [drive:], replacing [drive:] with the location of your USB drive. This will destroy any data on your USB drive! The drive shouldn’t be partitioned any larger than 1 GB. If it is, then repartition it using Computer Management in the Control Panel.
  11. Copy the Windows XP setup files to the USB drive (or another USB device if you have insufficient space left). You’ll only need the i386 folder.

If no errors occured in the process, you should now be all set to boot from USB!

Note: it’s possible to use Windows 2003 Server as the operating system to boot from, but I don’t recommend it. Many of BartPE’s included utilities won’t work properly.

Step Three: Configuring the BIOS

You should now reboot and go into the BIOS configuration to boot from USB. Instructions for doing so wildly from system to system, but generally entail the following:

  1. Reboot the system.
  2. While booting (before Windows starts loading), get into the BIOS configuration screen by hitting something like F1, F2, Delete or Escape. Hotkey instructions are generally provided on the screen.
  3. Go to the section that contains your boot devices.
  4. With your USB drive plugged in, the USB drive should be listed. If it isn’t, your system might not support booting from USB. Assuming that it is supported (as is the case with virtually all modern hardware), promote your USB drive to the primary boot device.
  5. Exit from the BIOS configuration, saving all changes.

If you’re completely new to BIOS configuration, BIOS for Beginners over at Tom’s Hardware might be a good primer. Be aware though, that you can seriously screw up your system by providing incorrect settings!

Step Four: Booting into BartPE

Assuming that you properly configured your BIOS and your USB device supports booting, BartPE should now load. Depending on the speed of your USB device, this may take a while.

If it isn’t working, then double-check the following before making a scene:

  • Is your BIOS properly configured for booting from the USB disk? (Is the USB device listed and does it have top priority?)
  • Have you correctly prepared the USB disk in step two? (Restart the procedure.)
  • Does your USB stick properly support being booted from? (Try another one!)

Step Five: Prepping the Hard Disk

You need to make sure that your hard drive is partitioned and formatted properly. Especially if you’ve had Linux or some other operating system on it, you’ll need to repartition and format it. BartPE contains DiskPart for disk partitioning and A43 File Manager to format your drive.

If you are sure that your hard drive is set up properly (i.e. it has only run Windows, it contains a valid FAT or NTFS partition) then you can safe yourself the hassle and skip this step.

This procedure will destroy any data on the hard drive.

To repartition:

  1. From the Go menu, navigate to DiskPart.
  2. Enter the commands needed to repartition your drive. For example, try the following: select disk 0 (select the first disk), clean (purges the entire drive, essentially resetting it), create partition primary (creates a single partition from the entire disk), assign (assign the partition a drive letter), exit (quits DiskPart).

This procedure will destroy any data on the hard drive.

To format:

  1. From the Go menu, navigate to the A43 File Manager.
  2. Right-click on the target drive (e.g. C:) and click Format. Should be self-explanatory.

Step Six: Launching Windows XP Setup

With your drive all ready, you can now launch the Windows XP setup with a few custom parameters. Let’s assume that the files are available at D:\i386.

Plugging in a device now won’t work. Remember that all USB devices will need to be plugged in right from the start while using BartPE.

  1. Run D:\i386\winnt32.exe /syspart:C: /tempdrive:C: /makelocalsource. Replace C: with the drive you want to install Windows to.
  2. Proceed with the installation. When asked to convert the installation volume to NTFS, answer No. The setup program incorrectly believes that your USB drive (which is formatted as FAT) needs conversion.

The setup program will then silently close, which might make you think that something went wrong. Don’t worry though. Reboot your system, remove the USB drive(s) and – if all went well – you can now finish setting up Windows XP. Congratulations!

All comments are highly welcome. Hope to have helped some of you out!

BLOG [in] TREND เรียกใช้งาน VMware Software (Portable)

เรียกใช้งาน VMware Software ผ่าน External Harddisk
โดย : BLOG [in] TREND | เมื่อวันที่ : 18.07.2008 | เวลา : 0:08 | จำนวนผู้อ่าน : 293 ครั้ง
หมวดหมู่ : ซอฟท์แวร์ | ป้าย : external, harddisk, vmware

เพื่อน ๆ คงจะ งง เรียกใช้งาน Vmware บน External Harddisk มันแปลกตรงไหนเนี่ย ก็คงจะไม่แปลกครับถ้าเครื่องที่เพื่อน ๆ เอา Vmware Image ไปเรียกใช้งานในเครื่องที่ได้ติดตั้ง Vmware Software ไว้อยู่แล้ว แต่ .. ถ้าบังเอิญจะเอา Image ไปเล่นที่ร้าน Internet Cafe หรือ เครื่องเพื่อนๆ คนอื่นละจะทำยังไงละ ..

ก็แค่ติดตั้ง .. Software ไงไม่เห็นจะยาก .. แต่ผมมีทางให้เพื่อน ๆ สามารถเรียกใช้งานได้จาก External Harddisk ได้เลยไม่ต้องติดตั้งที่เครื่องอื่น ๆ ละจะดีกว่าไหมครับ ลองมาดูนะครับ ว่าต้องทำอย่างไรบ้างง …

.. มาเร็วว เริ่มกันเลยดีกว่านะครับ .. ขั้นตอนง่าย ๆ มีดังนี้ครับ

1. สร้าง Vmware Image ที่ต้องการใช้งาน ก่อนจากเครื่องที่ได้ติดตั้ง Vmware Software ไว้แล้ว โดยสามารถสร้างได้จาก Vmware Workstation หรือถ้าติดตั้งผ่าน Vmware Player ก็ให้ไปสร้างไฟล์ .vmx เพื่อกำหนด Hardware จากเว็บ www.easyvmx.com ได้เลย
2. ติดตั้ง OS ที่ Vmware Image นี้
3. ก๊อบปี้ข้อมูล Vmware Image ไปที่ External Harddisk
4. ขั้นตอนนี้จะทำให้สามารถ เรียกใช้งาน Vmware Software บน External Harddisk ได้

* เปิดแฟ้ม Window Explorer ไปที่ Program File\VMWare\VMWare Workstation\
* คัดลอกไฟล์ vmplayer.exe, sigc-2.0.dll, vmcuiutil.dll, vmapputil.dll และ vmapplib.dll ไปที่ External Disk

5. เรียกใช้งาน Vmware Image โดยเลือกไฟล์ Image ทีมี นามสกุล .vmx เลือก Open With ไปยัง Path ที่ Vmware Player (vmplayer.exe)ที่ External Harddisk
6. ใช้งาน Vmware ของเราได้เลยยย ครับ ..

ขอให้เพื่อน ๆ ทำกันสำเร็จนะครับ … ส่วนผมจะเอาไปใช้กับงานลูกค้า เพราะว่าปกติลูกค้าไม่ค่อย ยอมให้ติดตั้ง Software อยู่แล้วทำแบบนี้สะดวกสุด ๆ แถมถ้าต้องการนำ Vmware ไปเก็บข้อมูลก็ทำได้งานแค่ Copy ไฟล์ทั้งหมดไป วางไว้ในเครื่อง ไม่ต้องติดตั้ง Software ด้วย และนำกลับมาตรวจสอบข้อมูลก็แค่ คัดลอกมาไว้ที่ External Harddisk เหมือนเดิมครับ สะดวกจริงโลก Virtualization

vmware player : http://www.vmware.com/download/player/

Thursday, June 19, 2008

วิธีการปรับแต่ง Windows XP ให้สามารถใช้งาน Multi Core

Windows XP Hotfix Patch: KB896256

ให้คลิก Start Menu > Run พิมพ์ REGEDIT แล้วกด enter

ตำแหน่งของ Registry จะอยู่ที่ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Session Manager โดยจะเห็นคำว่า Throttle อยู่จ้ะ

ถ้าไม่มีก็สร้างขึ้นมาเองซะเลยจ้ะ

โดยการ คลิกขวา New > Key แล้วตั้งชื่อว่า Throttle

ขั้นตอนที่ 3.

ในขั้นตอนนี้ก็ยังคงอยู่ใน Registry เช่นเดิมนะ

ใน Throttle ให้ควรมี DWORD ชื่อ PerfEnablePackageIdle โดยตั้งค่า Value ไว้ 1

ถ้าไม่มีก็เหมือนเดิมจ้ะ สร้างขึ้นมาเองเลย

โดยคลิกขวา New > DWORD แล้วตั้งชื่อ PerfEnablePackageIdle

***รายละเอียด ที่ตั้งไว้เท่ากับ 1 หมายถึงเปิดใช้งานจ้ะ คือเพิ่มประสิทธิภาพนั้นเอง


แล้วลองตรวจสอบดูจ้ะ ว่ามี /usepmtimer อยู่ในบรรทัดสุดท้ายรึเปล่า
boot.ini
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Micro soft Windows XP Professional" /noexecute=optin /fastdetect /usepmtimer

Tuesday, March 25, 2008

VB

Option Explicit

'Ñîñòàâèë Ãåðàñêèí Ðîìàí Âèêòîðîâè÷

'Mail To: Grv@Dioton.ru

'ÖÒÎ OOO "Äèîòîí" Êðàñíîÿðñê 03.2005 ã.

'Âíèìàíèå íåêîòîðûå òèïû äàííûõ ïîäìåíåíû !!!

'èñêëþ÷èòåëüíî äëÿ óäîáñòâà.

'Îïèñàíèå ôóíêöèé îðèãèíàëüíîå.

'Íóæíû ðîäíûå òèïû ñì. CipherLab.H

''**********************************************************************

'' Äàííàÿ âåðñèÿ áóäåò ðàáîòàòü ñ ïðîøèâêàìè íà÷èíàÿ ñ âåðñèè ÀÍ31

''**********************************************************************

''**********************************************************************

'' Äëÿ îáìåíà äàííûìè òåðìèíàë äîëæåí íàõîäèòüñÿ â ãëàâíîì ìåíþ.

'' Ïåðåä èñïîëüçîâàíèåì ôóíêöèè ðåêîìåíäóåòñÿ ïðîâåðèòü ñîñòîÿíèå òåðìèíàëà:

'' ëèáî Ping, ëèáî GetCurrentState (ÑÎÌ-ïîðò ìîæåò áûòü îòêðûò, à âîò

'' òåðìèíàë ìîæåò íàõîäèòüñÿ íå â ñòàðòîâîì ìåíþ).

'' Ïðîâåðêà íà ñîñòîÿíèå ÑÎÌ-ïîðòà (îòêðûò/íå îòêðûò) ïðîèçâîäèòñÿ âíóòðè

'' ôóíêöèé, òàê ÷òî âûçîâ CheckComm íåîáÿçàòåëåí.

'' Ôóíêöèè Ping è GetCurrentState ïðàêòè÷åñêè îäèíàêîâûå. GetCurrentState ïëàíèðóåòñÿ

'' ïåðåäåëàòü äëÿ îòîáðàæåíèÿ, ãäå íàõîäèòñÿ òåðìèíàë (ñòàðòîâîå ìåíþ, çàãðóçêà, âûãðóçêà è ò.ä.).

'' Òàê ÷òî ïîëüçîâàòüñÿ ìîæíî îáåèìè, íî ÿ ñîâåòóþ Ping ò.ê. GetCurrentState ìîæåò èçìåíèòüñÿ.

'' Ïåðåäåëûâàòü ïðèäåòñÿ íå òîëüêî ôóíêöèþ, íî è ïðîøèâêó òåðìèíàëà...

'' Óêàçàòåëü íà ñòðîêîâóþ ïåðåìåííóþ ðåêîìåíäóåòñÿ èñïîëüçîâàòü òèïà char szData[256]; ïðåîáðàçîâàííûé ê(LPSTR)szData

'' Ïîëå íå ìîæåò ïðåâûøàòü 256 áàéò, ñòðîêà áàçû äàííûõ íå ìîæåò ïðåâûøàòü 1024 áàéò.

'' Áàç äàííûõ ìîæåò áûòü äî òðåõ: îò 1 äî 3. Ôàéëîâ äàííûõ äî 10: îò 0 äî 9. Ýòî çàâèñèò îò

'' çàäà÷è, ñãåíåðèðîâàííîé â Ãåíåðàòîðå Ïðèëîæåíèé

'' Åñëè êàêàÿ-ëèáî ôóíêöèÿ âîçâðàòèëà îøèáêó, ýòà ôóíêèÿ äàñò å¸ ïîäðîáíîå îïèñàíèå

'' Òàêæå Âû ìîæåòå íàéòè îïèñàíèå îøèáîê â ôàéëå Errors.txt

'' Ïàðàìåòðû:

'' óêàçàòåëü íà ñòðîêîâóþ ïåðåìåííóþ, êóäà áóäåò ïîìåùåíî îïèñàíèå îøèáêè èëè NULL, åñëè íóæåí òîëüêî íîìåð

'' Âîçâðàùàåìîå çíà÷àíèå:

'' íîìåð îøèáêè

Public Declare Function GetError Lib "stdCipherLab.dll" Alias "stdGetError" (szData As Any) As Long

'' Ôóíêöèÿ:Îòêðûòü ÑÎÌ ïîðò

'' Ïàðàìåòðû:

'' int nCommPort - öåëîå, íîìåð ÑÎÌ-ïîðòà, 1..16

'' int nCommSpeed - öåëîå, ñêîðîñòü ÑÎÌ - ïîðòà, 1..5

'' (1 - 115200, 2 - 57600, 3 - 38400, 4 - 19200, 5 - 9600)

'' BOOL bIsIrDA - ëîãè÷åñêîå, åñëè îáìåí áóäåò ïðîèçâîäèòüñÿ ÷åðåç Ir àäàïòåð

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè ÑÎÌ ïîðò óñïåøíî îòêðûò

'' FALSE - èíà÷å.

Public Declare Function OpenComm Lib "stdCipherLab.dll" Alias "stdOpenComm" (ByVal nCommPort As Long, ByVal nCommSpeed As Long, ByVal bIsIrDA As Long) As Long

' Ôóíêöèÿ:ïðîâåðèòü ñîñòîÿíèå ÑÎÌ ïîðòà

' Ðåêîìåíäóåòñÿ âûçûâàòü äëÿ ïðîâåðêè ñîñòîÿíèÿ ÑÎÌ ïîðòà ïåðåä âûçîâîì ôóíêöèé.

' Ïàðàìåòðû:

' íåò

' Âîçâðàùàåìîå çíà÷àíèå:

' TRUE - åñëè ÑÎÌ ïîðò îòêðûò

' FALSE - èíà÷å.

Public Declare Function CheckComm Lib "stdCipherLab.dll" Alias "stdCheckComm" () As Long

' Ôóíêöèÿ:çàêðûòü ÑÎÌ ïîðò

' Ðåêîìåíäóåòñÿ âûçûâàòü ïåðåä âûõîäîì èç ïðèëîæåíèÿ.

' ÑÎÌ ïîðò ïðè âûõîäå âñå ðàâíî áóäåò çàêðûò, íî ëó÷øå íå ïîëàãàòüñÿ íà ñèñòåìó.

' Ïàðàìåòðû:

' íåò

' Âîçâðàùàåìîå çíà÷àíèå:

' íåò

Public Declare Sub CloseComm Lib "stdCipherLab.dll" Alias "stdCloseComm" ()

' Ôóíêöèÿ:ïðîâåðèòü íàëè÷èå òåðìèíàëà íà äàííîì ÑÎÌ ïîðòó.

' Òåðìèíàë äîëæåí íàõîäèòüñÿ â ãëàâíîì ìåíþ èëè ñîñòîÿíèè çàãðóçêè / âûíãðóçêè

' Ïàðàìåòðû:

' íåò

' Âîçâðàùàåìîå çíà÷àíèå:

' TRUE - åñëè òåðìèíàë îòîçâàëñÿ

' FALSE - èíà÷å.

Public Declare Function Ping Lib "stdCipherLab.dll" Alias "stdPing" () As Long

' Ôóíêöèÿ:ïîëó÷èòü êîë-âî ñâîáîäíîé ïàìÿòè

' Ïàðàìåòðû:

' íåò

' Âîçâðàùàåìîå çíà÷àíèå:

' äëèííîå öåëîå, êîë-âî ñâîáîäíîé ïàìÿòè â áàéòàõ

' 0 èëè íèæå ïðè âîçíèêíîâåíèè îøèáêè

Public Declare Function GetFreeMemory Lib "stdCipherLab.dll" Alias "stdGetFreeMemory" () As Long

' Ôóíêöèÿ:ïîëó÷èòü ñåðèéíûé íîìåð òåðìèíàëà

' Òåðìèíàë äîëæåí íàõîäèòüñÿ â ãëàâíîì ìåíþ èëè ñîñòîÿíèè çàãðóçêè / âûíãðóçêè

' Ïàðàìåòðû:

' óêàçàòåëü íà ñòðîêîâóþ ïåðåìåííóþ, êóäà áóäåò ïîìåùåí íîìåð òåðìèíàëà

' Âîçâðàùàåìîå çíà÷àíèå:

' TRUE - åñëè íîìåð ïåðåäàí

' FALSE - èíà÷å.

Public Declare Function GetSerialNumber Lib "stdCipherLab.dll" Alias "stdGetSerialNumber" (szData$) As Long

' Ôóíêöèÿ:ïîëó÷èòü òåêóùåå ñèñòåìíîå âðåìÿ òåðìèíàëà

' Òåðìèíàë äîëæåí íàõîäèòüñÿ â ãëàâíîì ìåíþ èëè ñîñòîÿíèè çàãðóçêè / âûíãðóçêè

' Ïàðàìåòðû:

' óêàçàòåëü íà ñòðîêîâóþ ïåðåìåííóþ, êóäà áóäåò ïîìåùåíî âðåìÿ òåðìèíàëà â ôîðìàòå ÃÃÃÃÌÌÄÄ××ÌÌÑÑ

' Âîçâðàùàåìîå çíà÷àíèå:

' TRUE - åñëè âðåìÿ ïîëó÷åíî

' FALSE - èíà÷å.

Public Declare Function GetTime Lib "stdCipherLab.dll" Alias "stdGetTime" (szData$) As Long

' Ôóíêöèÿ:îáíîâèòü âðåìÿ òåðìèíàëà

' Â òåðìèíàë áóäåò ïåðåäàííî ñèñòåìíîå âðåìÿ

' Ïàðàìåòðû:

' íåò

' Âîçâðàùàåìîå çíà÷àíèå:

' TRUE - åñëè âðåìÿ îáíîâëåííî

' FALSE - èíà÷å.

Public Declare Function UpdateTime Lib "stdCipherLab.dll" Alias "stdUpdateTime" () As Long

' Ôóíêöèÿ:ïðîâåðÿåò - íàõîäèòñÿ ëè òåðìèíàë â ñòàðòîâîì ìåíþ (ãîòîâíîñòü ê îáìåíó äàííûìè)

' Ïàðàìåòðû:

' íåò

' Âîçâðàùàåìîå çíà÷àíèå:

' TRUE - åñëè òåðìèíàë ãîòîâ ê ðàáîòå (íàõîäèòñÿ â ñòàðòîâîì ìåíþ)

' FALSE - èíà÷å.

Public Declare Function GetCurrentState Lib "stdCipherLab.dll" Alias "stdGetCurrentState" () As Long

'' Ôóíêöèÿ:ïîëó÷èòü êîë-âî çàïèñåé â äîêóìåíòå íîìåð (0-9)

'' Ïàðàìåòðû:

'' íîìåð äîêóìåíòà (0-9)

'' Âîçâðàùàåìîå çíà÷àíèå:

'' äëèííîå öåëîå, êîë-âî çàïèñåé

'' -1 ïðè âîçíèêíîâåíèè îøèáêè

Public Declare Function GetDataCount Lib "stdCipherLab.dll" Alias "stdGetDataCount" (ByVal nDoc&) As Long

'' Ôóíêöèÿ:ïîëó÷èòü êîë-âî çàïèñåé â Áàçå Äàííûõ íîìåð (1-3)

'' Ïàðàìåòðû:

'' íîìåð Áàçû äàííûõ (1-3)

'' Âîçâðàùàåìîå çíà÷àíèå:

'' äëèííîå öåëîå, êîë-âî çàïèñåé

'' -1 ïðè âîçíèêíîâåíèè îøèáêè

Public Declare Function GetRecordsCount Lib "stdCipherLab.dll" Alias "stdGetRecordsCount" (ByVal nBase&) As Long

'' Ôóíêöèÿ:î÷èñòèòü ñîäåðæèìîå äîêóìåíòà íîìåð (0-9)

'' Ïàðàìåòðû:

'' íîìåð äîêóìåíòà (0-9)

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè óñïåøíî î÷èùåííî

'' FALSE - èíà÷å.

Public Declare Function ClearDoc Lib "stdCipherLab.dll" Alias "stdClearDoc" (ByVal nDoc&) As Long

'' Ôóíêöèÿ:î÷èñòèòü ñîäåðæèìîå Áàçû Äàííûõ íîìåð (1-3)

'' Ïàðàìåòðû:

'' íîìåð Áàçû äàííûõ (1-3)

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè óñïåøíî î÷èùåííî

'' FALSE - èíà÷å.

Public Declare Function ClearDB Lib "stdCipherLab.dll" Alias "stdClearDB" (ByVal nBase&) As Long

'' Ôóíêöèÿ:ïîëó÷èòü î÷åðåäíóþ çàïèñü èç äîêóìåíòà íîìåð (0-9)

'' Åñëè òåðìèíàë íàõîäèòüñÿ â ãëàâíîì ìåíþ, îí áóäåò ïåðåâåäåí â ñîñòîÿíèå âûãðóçêè

'' Ïàðàìåòðû:

'' íîìåð äîêóìåíòà (0-9)

'' óêàçàòåëè íà ñòðîêîâûå ïåðåìåííûå, êóäà áóäóò ïîìåùåíû ïîëÿ äîêóìåíòà

'' Âîçâðàùàåìîå çíà÷àíèå:

'' 1 - óñïåøíî!

'' 0 çàïèñåé íåò, îáìåí çàâåðøåí

'' -1 ïðè âîçíèêíîâåíèè îøèáêè

'Public Declare Function ReadData Lib "stdCipherLab.dll" Alias "stdReadData" (ByVal nDoc&, szData1$, szData2$, szData3$, szData4$, szData5$, szData6$, szData7$, szData8$) As Long

Public Declare Function ReadData Lib "stdCipherLab.dll" Alias "stdReadData" (ByVal nDoc&, szData1 As Any, szData2 As Any, szData3 As Any, szData4 As Any, szData5 As Any, szData6 As Any, szData7 As Any, szData8 As Any) As Long

'Public Declare Function ReadData Lib "stdCipherLab.dll" Alias "stdReadData" (ByVal nDoc&, szData1 As FField, szData2 As FField, szData3 As FField, szData4 As FField, szData5 As FField, szData6 As FField, szData7 As FField, szData8 As FField) As Long

'' Ôóíêöèÿ:ïîëó÷èòü î÷åðåäíóþ çàïèñü èç äîêóìåíòà (0) èëè Áàçû Äàííûõ íîìåð (1-3)

'' Åñëè òåðìèíàë íàõîäèòüñÿ â ãëàâíîì ìåíþ, îí áóäåò ïåðåâåäåí â ñîñòîÿíèå âûãðóçêè

'' Ïàðàìåòðû:

'' íîìåð Áàçû äàííûõ (1-3)

'' óêàçàòåëè íà ñòðîêîâûå ïåðåìåííûå, êóäà áóäóò ïîìåùåíû ïîëÿ áàçû äàííûõ

'' Âîçâðàùàåìîå çíà÷àíèå:

'' 1 - óñïåøíî!

'' 0 çàïèñåé íåò, îáìåí çàâåðøåí

'' -1 èëè íèæå ïðè âîçíèêíîâåíèè îøèáêè

'Public Declare Function ReadRecord Lib "stdCipherLab.dll" Alias "stdReadRecord" (ByVal nBase&, szData1$, szData2$, szData3$, szData4$, szData5$, szData6$, szData7$, szData8$) As Long

Public Declare Function ReadRecord Lib "stdCipherLab.dll" Alias "stdReadRecord" (ByVal nBase&, szData1 As Any, szData2 As Any, szData3 As Any, szData4 As Any, szData5 As Any, szData6 As Any, szData7 As Any, szData8 As Any) As Long

'Public Declare Function ReadRecord Lib "stdCipherLab.dll" Alias "stdReadRecord" (ByVal nBase&, szData1 As FField, szData2 As FField, szData3 As FField, szData4 As FField, szData5 As FField, szData6 As FField, szData7 As FField, szData8 As FField) As Long

'' Ôóíêöèÿ:çàãðóçèòü çàïèñü â Áàçó Äàííûõ íîìåð (1-3)

'' Åñëè òåðìèíàë íàõîäèòüñÿ â ãëàâíîì ìåíþ, îí áóäåò ïåðåâåäåí â ñîñòîÿíèå çàãðóçêè äûííûõ

'' Ïàðàìåòðû:

'' íîìåð Áàçû äàííûõ (1-3)

'' óêàçàòåëü íà çàãðóæàåìûå ïîëÿ áàçû äàííûõ

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè çàïèñü óñïåøíî çàãðóæåíà

'' FALSE - èíà÷å.

Public Declare Function PutRecord Lib "stdCipherLab.dll" Alias "stdPutRecord" (ByVal nBase&, szData1 As Any, szData2 As Any, szData3 As Any, szData4 As Any, szData5 As Any, szData6 As Any, szData7 As Any, szData8 As Any) As Long

'' Äëÿ çàâåðøåíèÿ çàãðóçêè è ñòàðòà èíäåêñèðîâàíèÿ èñïîëüçóéòå äàííóþ ôóíêöèþ

'' Ïàðàìåòðû:

'' íåò

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè çàãðóçêà óñïåøíî çàâåðøåíà

'' FALSE - èíà÷å.

Public Declare Function Finish Lib "stdCipherLab.dll" Alias "stdFinish" () As Long

'' Ïîêàçûâàåò ñîîáùåíèå î õîäå âûïîëíåíèÿ ïåðåäà÷è äàííûõ

'' Ïàðàìåòðû:

'' int nAction - 1 Âûñâå÷èâàåòñÿ íàäïèñü "Îñòàëîñü ïîëó÷èòü: %d çàïèñåé"

'' - 0 Âûñâå÷èâàåòñÿ íàäïèñü "Îñòàëîñü ïåðåäàòü: %d çàïèñåé"

'' int nCount - ÷èñëî, êîòîðîå áóäåò ïîäñòàâëÿòüñÿ â íàäïèñå.

'' Âîçâðàùàåìîå çíà÷àíèå:

'' íåò

Public Declare Sub ShowProgress Lib "stdCipherLab.dll" Alias "stdShowProgress" (ByVal nAction As Long, ByVal nCount As Long)

'' Èçìåíÿåò çíà÷åíèå ðàçäåëèòåëåé â ïîëÿõ áàçû è äîêóìåíòà

'' Ïàðàìåòðû:

'' char Base - ðàçäåëèòåëü äëÿ ïîëåé áàçû, ïî óìîë÷àíèå êîä 9 (òàáóëÿöèÿ)

'' char Doc - ðàçäåëèòåëü äëÿ ïîëåé áàçû, ïî óìîë÷àíèå êîä 9 (òàáóëÿöèÿ)

'' Âîçâðàùàåìîå çíà÷àíèå:

'' íåò

Public Declare Sub Delimiter Lib "stdCipherLab.dll" Alias "stdDelimiter" (ByVal Base As Byte, ByVal Doc As Byte)

'' Çàãðóæàåò äàííûå â áàçó èç ôàéëà

'' Ïàðàìåòðû:

'' nBase - íîìåð Áàçû äàííûõ (1-3)

'' nPath - óêàçàòåëü íà ñòðîêîâóþ ïåðåìåííóþ, ãäå ïåðåäàåòñÿ ïóòü ê ôàéëó

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè îáìåí óñïåøíî çàâåðøåí

'' FALSE - èíà÷å.

Public Declare Function FileToBase Lib "stdCipherLab.dll" Alias "stdFileToBase" (ByVal nBase As Long, ByVal nPath As String) As Long

'' Âûãðóæàåò èç òåðìèíàëà äîêóìåíò è çàïèñûâàåò â ôàéë

'' Ïàðàìåòðû:

'' nDoc - íîìåð äîêóìåíòà (0-9)

'' nPath - óêàçàòåëü íà ñòðîêîâóþ ïåðåìåííóþ, ãäå ïåðåäàåòñÿ ïóòü ê ôàéëó

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè îáìåí óñïåøíî çàâåðøåí

'' FALSE - èíà÷å.

Public Declare Function DocToFile Lib "stdCipherLab.dll" Alias "stdDocToFile" (ByVal nDoc As Long, ByVal nPath As String) As Long

'' Âûãðóæàåò èç òåðìèíàëà áàçó è çàïèñûâàåò â ôàéë

'' Ïàðàìåòðû:

'' nBase - íîìåð Áàçû äàííûõ (1-3)

'' nPath - óêàçàòåëü íà ñòðîêîâóþ ïåðåìåííóþ, ãäå ïåðåäàåòñÿ ïóòü ê ôàéëó

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè îáìåí óñïåøíî çàâåðøåí

'' FALSE - èíà÷å.

Public Declare Function BaseToFile Lib "stdCipherLab.dll" Alias "stdBaseToFile" (ByVal nBase As Long, ByVal nPath As String) As Long

'' Ôóíêöèÿ:îáíîâèòü çàïèñü â Áàçå Äàííûõ íîìåð (1-3)

'' Åñëè òåðìèíàë íàõîäèòüñÿ â ãëàâíîì ìåíþ, îí áóäåò ïåðåâåäåí â ñîñòîÿíèå çàãðóçêè äûííûõ

'' Ïàðàìåòðû:

'' íîìåð Áàçû äàííûõ (1-3)

'' óêàçàòåëü íà çàãðóæàåìûå ïîëÿ áàçû äàííûõ

'' Âîçâðàùàåìîå çíà÷àíèå:

'' TRUE - åñëè çàïèñü óñïåøíî çàãðóæåíà

'' FALSE - èíà÷å.

Public Declare Function UpdateRecord Lib "stdCipherLab.dll" Alias "stdUpdateRecord" (ByVal nBase&, szData1 As Any, szData2 As Any, szData3 As Any, szData4 As Any, szData5 As Any, szData6 As Any, szData7 As Any, szData8 As Any) As Long

Public Declare Function GetDelay Lib "stdCipherLab.dll" Alias "stdGetDelay" () As Long

Public Declare Function SetDelay Lib "stdCipherLab.dll" Alias "stdSetDelay" (ByVal Delay As Long) As Long

Public Declare Function ClearDBField Lib "stdCipherLab.dll" Alias "stdClearDBField" (ByVal Base As Long, ByVal Field As Long) As Long

' Äóáëèðóåò GetError

Public Function GetErrorDescription(ByVal RetCode As Long) As String

Dim sMsg As String

Select Case RetCode

Case 0

sMsg = "Îïåðàöèÿ áûëà çàâåðøåíà óñïåøíî!"

Case 1

sMsg = "COM ïîðò íå èíèöèàëèçèðîâàí!"

Case 2

sMsg = "Íåâîçìîæíî îòêðûòü COM ïîðò!"

Case 3

sMsg = "Íåâîçìîæíî íàñòðîèòü COM ïîðò!"

Case 4

sMsg = "Íåâîçìîæíî íàñòðîèòü IR àäàïòåð!"

Case 5

sMsg = "Îøèáêà ÑÎÌ ïîðòà!"

Case 6

sMsg = "Ñëèøêîì êîðîòêèå äàííûå äëÿ ïåðåäà÷è!"

Case 7

sMsg = "Ñëèøêîì äëèííûå äàííûå äëÿ ïåðåäà÷è!"

Case 8

sMsg = "Òàéì - àóò! Äàííûå íå ïåðåäàíû!"

Case 9

sMsg = "Îøèáêà ïåðåäà÷è äàííûõ! Äàííûå íå ïåðåäàíû!"

Case 10

sMsg = "Ôîðìàò Áàçû Äàííûõ íå îïðåäåëåí!"

Case 11

sMsg = "Îòâåò òåðìèíàëà ACK íå ñîîòâåòñòâóåò îæèäàåìîìó!"

Case 12

sMsg = "Îòâåò òåðìèíàëà NAK íå ñîîòâåòñòâóåò îæèäàåìîìó!"

Case 13

sMsg = "Îòâåò òåðìèíàëà OVER íå ñîîòâåòñòâóåò îæèäàåìîìó!"

Case 14

sMsg = "Îòâåò òåðìèíàëà OK íå ñîîòâåòñòâóåò îæèäàåìîìó!"

Case 15

sMsg = "Îòâåò òåðìèíàëà ERR íå ñîîòâåòñòâóåò îæèäàåìîìó!"

Case 16

sMsg = "Íåèçâåñòíûé îòâåò òåðìèíàëà!"

Case 17

sMsg = "Ñëèøêîì äëèííûå äàííûå äëÿ ïðèåìà!"

Case 18

sMsg = "Íåâîçìîæíî ïðåðâåñòè òåðìèíàë â ðåæèì çàãðóçêè!"

Case 19

sMsg = "Ïåðåïîëíåíèå ïàìÿòè!Çàâåðøåíî!"

Case 20

sMsg = "Íåò äàííûõ äëÿ ïåðåäà÷è!"

Case 21

sMsg = "Íåâåðíûå íàñòðîéêè ïîðòà!"

Case 22

sMsg = "Íåâåðíûé äèàïàçîí áàçû (1..3)!"

Case 23

sMsg = "Íåâåðíûé äèàïàçîí äîêóìåíòà (0..9)!"

Case 24

sMsg = "Ïåðåäàí ïàðàìåòð íåâåðíîãî òèïà!"

Case 25

sMsg = "Îøèáêà îáíîâëåíèÿ âðåìåíè!"

Case 26

sMsg = "Áàçà íå îïðåäåëåíà. Ñîçäàéòå áàçó äàííûõ â çàäà÷å!"

Case 27

sMsg = "Áàçà íå ðàçðåøåíà äëÿ âûãðóçêè. Èçìåíèòå íàñòðîêè â çàäà÷å!"

Case 28

sMsg = "Ôàéë îáìåíà íå íàéäåí!"

Case 29

sMsg = "Îøèáêà ÷òåíèÿ ôàéëà!"

Case 30

sMsg = "Íåâîçìîæíî çàïèñàòü â ôàéë!"

Case 31

sMsg = "Ôàéë çàùèùåí îò çàïèñè!"

Case 32

sMsg = "Óêàçàííûé íåâåðíûé ïóòü ê ôàéëó!"

Case 33

sMsg = "Ïîëå ÁÄ óêàçàíî íåâåðíî!"

Case 34

sMsg = "Íàðóøåíà ïîñëåäîâàòåëüíîñòü çàïèñåé! Ñîîáùèòå ïîæàëóéñòà ðàçðàáîò÷èêó!"

End Select

GetErrorDescription = sMsg

End Function

Public Function GetStopError() As Boolean

Dim sMsg As String, ErrCode As Long

sMsg = String(256, " ")

ErrCode = GetError(ByVal sMsg)

sMsg = Trim(sMsg)

MsgBox Prompt:=sMsg & " Êîä: " & CStr(ErrCode), buttons:=vbCritical, Title:="CipherLab.Dll Error !"

' Îøèáêè ïî êîòîðûì ñòîèò è âûéòè èç öèêëà

Select Case ErrCode

Case 8, 9, 27, 13, 15

GetStopError = True

Case 19, 34

If Ping <> 1 Then Finish ' Òóò íóæíî ïîäóìàòü

GetStopError = True

End Select

End Function

Function GetVbError() As String 'Óïàêîâàë GetError

Dim ErrNum As Long, strErr As String

strErr = String(256, " ")

ErrNum = GetError(ByVal strErr)

strErr = RTrim(strErr)

GetVbError = "Êîä îøèáêè: " & CStr(ErrNum) & " Îïèñàíèå: " & strErr

End Function

' ×èñòî äëÿ ñåáÿ, âàì íè êàêîé ïîëüçû

Public Function GetMessageOK(ByVal mCode As Long) As String

Dim sMsg As String

Select Case mCode

Case 0

sMsg = Empty

Case 1

sMsg = "Îïåðàöèÿ çàâåðøåíà óñïåøíî"

Case 2

sMsg = "Êîì Ïîðò îòêðûò óñïåøíî"

Case 3

sMsg = "Òåðìèíàë â ãëàâíîì Ìåíþ"

Case 4

sMsg = "Ïîðò îòêðûò"

Case 5

sMsg = "Íîâîå Âðåìÿ è Äàòà - óñòàíîâëåíû"

End Select

GetMessageOK = sMsg

End Function