C++ Builder работа с lpt портом

Модератор: Fastman

Правила форума
Убедительная просьба юзать теги [code] при оформлении листингов.
Сообщения не оформленные должным образом имеют все шансы быть незамеченными.
paradox
проходил мимо
Сообщения: 11620
Зарегистрирован: 2008-02-21 18:15:41

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение paradox » 2009-04-07 16:06:39

tray.irk писал(а):делал по этой статье ... http://www.pcports.ru/articles/3.php

но увы не работает (((
Главным достоинством этого драйвера, является то, что обращения к порту могут быть сделаны и с помощью функций, работающих только в Windows 9x!

Хостинговая компания Host-Food.ru
Хостинг HostFood.ru
 

Услуги хостинговой компании Host-Food.ru

Хостинг HostFood.ru

Тарифы на хостинг в России, от 12 рублей: https://www.host-food.ru/tariffs/hosting/
Тарифы на виртуальные сервера (VPS/VDS/KVM) в РФ, от 189 руб.: https://www.host-food.ru/tariffs/virtualny-server-vps/
Выделенные сервера, Россия, Москва, от 2000 рублей (HP Proliant G5, Intel Xeon E5430 (2.66GHz, Quad-Core, 12Mb), 8Gb RAM, 2x300Gb SAS HDD, P400i, 512Mb, BBU):
https://www.host-food.ru/tariffs/vydelennyi-server-ds/
Недорогие домены в популярных зонах: https://www.host-food.ru/domains/

Аватара пользователя
tray.irk
сержант
Сообщения: 266
Зарегистрирован: 2008-10-22 8:21:36
Откуда: Иркутск
Контактная информация:

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение tray.irk » 2009-04-07 16:26:11

ладно вот по этой статье http://www.pcports.ru/articles/7.php .... но нужно перевести в форму всё это
Числа не управляют миром, но могут показать как управляется мир

Аватара пользователя
Fastman
ст. лейтенант
Сообщения: 1236
Зарегистрирован: 2006-07-07 10:20:38
Откуда: Минск. РБ

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение Fastman » 2009-04-07 16:26:20

tray.irk писал(а):да и я делал с формами ... может что то не так написал .... как будет выглядеть данный код на форме? что бы одна кнопка включить .... вторая выключить?
Балин...пускаюсь во все тяжкие....
У тебя есть форма и 2 кнопки - ты все это дело видишь в дизайнере форм.
После того как ты жмякаешь на кнопку - у тя создается метод-обработчик который будет выполнятся при нажатии на эту кнопку.
В этот метод ты запихиваешь код который и будет писать в твой LPT порт.
Только не забывай про драйвер giveio.sys который позволяет работать в NT системах с внешними портами, потому что из обычного так сказать юзерспейса в линейке NT прямой доступ к хардварным портам - запрещен на уровне системы.
Главное в жизни здоровье и любовь, остальное я все куплю.

Аватара пользователя
tray.irk
сержант
Сообщения: 266
Зарегистрирован: 2008-10-22 8:21:36
Откуда: Иркутск
Контактная информация:

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение tray.irk » 2009-04-07 16:32:21

ну кто нить дайте примерный рабочий код? с какими библиотеками и всё такое .... умоляю
Числа не управляют миром, но могут показать как управляется мир

Аватара пользователя
Fastman
ст. лейтенант
Сообщения: 1236
Зарегистрирован: 2006-07-07 10:20:38
Откуда: Минск. РБ

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение Fastman » 2009-04-07 16:42:38

tray.irk писал(а):ну кто нить дайте примерный рабочий код? с какими библиотеками и всё такое .... умоляю
Никто за тебя писать не будет.
Или ты думаешь что все бросят..найдут инстальник билдера и будудут писать тебе ???
Я могу конечно, но мое время будет довольно дорого стоить :)
Главное в жизни здоровье и любовь, остальное я все куплю.

Аватара пользователя
tray.irk
сержант
Сообщения: 266
Зарегистрирован: 2008-10-22 8:21:36
Откуда: Иркутск
Контактная информация:

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение tray.irk » 2009-04-07 16:51:10

эх ((( мне бы только начало понять ... а я бы дальше развил бы мысль .... ((( эх ...
Числа не управляют миром, но могут показать как управляется мир


Аватара пользователя
tray.irk
сержант
Сообщения: 266
Зарегистрирован: 2008-10-22 8:21:36
Откуда: Иркутск
Контактная информация:

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение tray.irk » 2009-04-08 4:50:44

нужно на С++ это написать ... что бы ткнул по кнопке ... она подала цифру 8 на порт lpt ....
Числа не управляют миром, но могут показать как управляется мир

Аватара пользователя
ProFTP
подполковник
Сообщения: 3388
Зарегистрирован: 2008-04-13 1:50:04
Откуда: %&й
Контактная информация:

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение ProFTP » 2009-04-08 5:08:46

там вроде бы не очень сложно, всего 8 методов, на сокеты не много похоже... типо: читать и писать :drinks:
Pеrl FAQ
perl -e 'print join"",map $$_[rand@$_],([0..9,'a'..'z','A'..'Z'])x30'
ИзображениеИзображение

Аватара пользователя
tray.irk
сержант
Сообщения: 266
Зарегистрирован: 2008-10-22 8:21:36
Откуда: Иркутск
Контактная информация:

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение tray.irk » 2009-04-08 9:52:57

ProFTP ... можешь написать пример? рабочий пример? очень нужно ... (((
Числа не управляют миром, но могут показать как управляется мир

de-signer
сержант
Сообщения: 220
Зарегистрирован: 2007-05-11 14:39:01
Откуда: Отсюда :)

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение de-signer » 2009-05-18 20:54:42

2tray.irk
Смею спросить: ты под виндой пишешь на билдере?
Если "да", тогда чем Windows SDK не устраивает? Там есть инструментарий по работе с портами ввода/вывода.
---
"Если я рассуждаю логично, то это значит только то, что я не сумашедший, но вовсе не доказывает, что я прав" (с)И.П.Павлов

Аватара пользователя
tray.irk
сержант
Сообщения: 266
Зарегистрирован: 2008-10-22 8:21:36
Откуда: Иркутск
Контактная информация:

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение tray.irk » 2009-05-19 4:18:53

да я пишу под виндой ... можно по подробнее? как это сделать?
Числа не управляют миром, но могут показать как управляется мир

de-signer
сержант
Сообщения: 220
Зарегистрирован: 2007-05-11 14:39:01
Откуда: Отсюда :)

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение de-signer » 2009-05-19 13:12:08

2tray.irk
Ленишься или справки у билдера нет?
Windows SDK писал(а):A process uses the CreateFile function to open a handle to a communications resource. For example, specifying COM1 opens a handle to a serial port, and LPT1 opens a handle to a parallel port. If the specified resource is currently being used by another process, CreateFile fails. Any thread of the process can use the handle returned by CreateFile to identify the resource in any of the functions that access the resource.

When using CreateFile to open a handle directly to a device, an application must use the special characters " \\ .\" to identify the device. For example, to open a handle to drive A, specify " \\ .\a:" for the lpszName parameter of CreateFile. The calling process can use the handle in the DeviceIoControl function to send control codes to the device.
When the process calls CreateFile to open a communications resource, it specifies the following attributes:

? What type of read-write access exists for the specified resource.
? Whether the handle can be inherited by child processes.
? Whether the handle can be used in overlapped (asynchronous) I/O operations. (For a description of overlapped operations, see Synchronization.)



When the process uses CreateFile to open a communications resource, it must specify certain values for the following parameters:

? The fdwShareMode parameter must be zero, opening the resource for exclusive access.
? The fdwCreate parameter must specify the OPEN_EXISTING flag.
? The hTemplateFile parameter must be NULL.
Windows SDK писал(а):The OpenFile function creates, opens, reopens, or deletes a file.

This function is provided for compatibility with 16-bit versions of Windows. In particular, the OpenFile function cannot open a named pipe. Win32-based applications should use the CreateFile function.

HFILE OpenFile(

LPCSTR lpFileName, // pointer to filename
LPOFSTRUCT lpReOpenBuff, // pointer to buffer for file information
UINT uStyle // action and attributes
);


Parameters

lpFileName

Points to a null-terminated string that names the file to be opened. The string must consist of characters from the Windows 3.x character set. The OpenFile function does not support Unicode filenames.

lpReOpenBuff

Points to the OFSTRUCT structure that receives information about the file when it is first opened. The structure can be used in subsequent calls to the OpenFile function to refer to the open file.
The OFSTRUCT structure contains a pathname string member whose length is limited to OFS_MAXPATHNAME characters. OFS_MAXPATHNAME is currently defined to be 128. Because of this, you cannot use the OpenFile function to open a file whose path length exceeds 128 characters. The CreateFile function does not have such a path length limitation.

uStyle

Specifies the action to take. The following values can be combined by using the bitwise OR operator:

Value Meaning
OF_CANCEL Ignored. In the Win32 application programming interface (API), the OF_PROMPT style produces a dialog box containing a Cancel button.
OF_CREATE Creates a new file. If the file already exists, it is truncated to zero length.
OF_DELETE Deletes the file.
OF_EXIST Opens the file and then closes it. Used to test for a file's existence.
OF_PARSE Fills the OFSTRUCT structure but carries out no other action.
OF_PROMPT Displays a dialog box if the requested file does not exist. The dialog box informs the user that Windows cannot find the file, and it contains Retry and Cancel buttons. Choosing the Cancel button directs OpenFile to return a file-not-found error message.
OF_READ Opens the file for reading only.
OF_READWRITE Opens the file for reading and writing.
OF_REOPEN Opens the file using information in the reopen buffer.
OF_SHARE_COMPAT For MS-DOS-based file systems using the Win32 API, opens the file with compatibility mode, allowing any process on a specified computer to open the file any number of times. Other efforts to open with any other sharing mode fail. Windows NT: This flag is mapped to the CreateFile function's FILE_SHARE_READ | FILE_SHARE_WRITE flags.
OF_SHARE_DENY_NONE Opens the file without denying read or write access to other processes. On MS-DOS-based file systems using the Win32 API, if the file has been opened in compatibility mode by any other process, the function fails. Windows NT: This flag is mapped to the CreateFile function's FILE_SHARE_READ | FILE_SHARE_WRITE flags.
OF_SHARE_DENY_READ Opens the file and denies read access to other processes. On MS-DOS-based file systems using the Win32 API, if the file has been opened in compatibility mode or for read access by any other process, the function fails. Windows NT: This flag is mapped to the CreateFile function's FILE_SHARE_WRITE flag.
OF_SHARE_DENY_WRITE Opens the file and denies write access to other processes. On MS-DOS-based file systems using the Win32 API, if the file has been opened in compatibility mode or for write access by any other process, the function fails. Windows NT: This flag is mapped to the CreateFile function's FILE_SHARE_READ flag.
OF_SHARE_EXCLUSIVE Opens the file with exclusive mode, denying both read and write access to other processes. If the file has been opened in any other mode for read or write access, even by the current process, the function fails.
OF_VERIFY Verifies that the date and time of the file are the same as when it was previously opened. This is useful as an extra check for read-only files.
OF_WRITE Opens the file for writing only.


Return Values

If the function succeeds, the return value specifies a file handle.
If the function fails, the return value is HFILE_ERROR. To get extended error information, call GetLastError.

Remarks

If the lpFileName parameter specifies a filename and extension only, this function searches for a matching file in the following directories, in the order shown:

1. The directory from which the application loaded.
2. The current directory.
3. Windows 95: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.

Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.

4. Windows NT: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.
5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6. The directories that are listed in the PATH environment variable.



The lpFileName parameter cannot contain wildcard characters.
The Win32 OpenFile function does not support the OF_SEARCH flag supported by the 16-bit Windows OpenFile function. The OF_SEARCH flag directs Windows to search for a matching file even when the filename includes a full path. To search for a file in a Win32-based application, use the SearchPath function.
---
"Если я рассуждаю логично, то это значит только то, что я не сумашедший, но вовсе не доказывает, что я прав" (с)И.П.Павлов

boor
рядовой
Сообщения: 23
Зарегистрирован: 2009-04-23 8:34:20

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение boor » 2009-05-20 4:49:09

Я как-то писал такое дело, но под qt под виндами. Даже где-то исходники остались. Если решитесь попробовать воспользоваться связкой mingw+qt для проекта, могу поделиться.

Аватара пользователя
tray.irk
сержант
Сообщения: 266
Зарегистрирован: 2008-10-22 8:21:36
Откуда: Иркутск
Контактная информация:

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение tray.irk » 2009-05-20 5:15:59

мне бы кто нить поделился бы исходником на формах ... для Builder C++
Числа не управляют миром, но могут показать как управляется мир

boor
рядовой
Сообщения: 23
Зарегистрирован: 2009-04-23 8:34:20

Re: C++ Builder работа с lpt портом

Непрочитанное сообщение boor » 2009-05-20 8:38:05

Очередная библиотека. Брать тут: http://exalted.ru/dlportio.zip
Там внутри мануал и исходники, в том числе для билдера.