|
Комрады, доброго всем времени суток. Кто в настроении, подсобите plz, как blob разодрать?
|
|||
---|---|---|---|
#18+
PB 12 работаю с GetOpenFileName function: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646927(v=vs.85).aspx OPENFILENAME structure: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx При выборе больше чем одного файла, lpstrFile возвращает блоб в котором null separated string /* lpstrFile Type: LPTSTR The file name used to initialize the File Name edit control. The first character of this buffer must be NULL if initialization is not necessary. When the GetOpenFileName or GetSaveFileName function returns successfully, this buffer contains the drive designator, path, file name, and extension of the selected file. If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer contains the current directory followed by the file names of the selected files. For Explorer-style dialog boxes, the directory and file name strings are NULL separated, with an extra NULL character after the last file name. For old-style dialog boxes, the strings are space separated and the function uses short file names for file names with spaces. You can use the FindFirstFile function to convert between long and short file names. If the user selects only one file, the lpstrFile string does not have a separator between the path and file name. If the buffer is too small, the function returns FALSE and the CommDlgExtendedError function returns FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the lpstrFile buffer contain the required size, in bytes or characters. */ пытаюсь её разодрать, чтобы достать имена файлов, получаетса только первое значение, что есть path к этим файлам, а дальше абракадабра из иероглифоф, посреваю, что что-то с юникодом. Если кто делал уже, подсобите плиз, буду предельно благодарен. мерси пс ... |
|||
:
Нравится:
Не нравится:
|
|||
17.10.2014, 17:06 |
|
Комрады, доброго всем времени суток. Кто в настроении, подсобите plz, как blob разодрать?
|
|||
---|---|---|---|
#18+
voronk, 1) Вам надо учитывать что в ПБ12 null-separated string означает, строку в которой каждый символ занимает 2 байта, и строка заканчивается двумя 0 байтами. И в конце после всех строк еще два 0 байта. 2) Чтобы ф-я работала корректно, надо параметр lpstrFile объявить ref Blob и перед вызовом выделить достаточное колво памяти в ней. 3) Потом вам надо поочередно находить позиции этих 0 байтов и извлекать строки между ними. 4) Извлечение байтов из блоба делается через BlobMid() 5) Схематичный код: Код: sql 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
... |
|||
:
Нравится:
Не нравится:
|
|||
17.10.2014, 17:40 |
|
Комрады, доброго всем времени суток. Кто в настроении, подсобите plz, как blob разодрать?
|
|||
---|---|---|---|
#18+
Спасибо за ответ Анатолий. Можно нам перейти на ТЫ? Тлько что обратил внимайие откуда ты ... любимый город, бывал там неоднократно, я сам из Кишинёва, 3.5 часа на дизеле и ы вас в гостях, правда давно это было. Но ближе к телу (с) Идею понял, попробовал, что-то не то ... может собака порылась здесь? 2) Чтобы ф-я работала корректно, надо параметр lpstrFile объявить ref Blob и перед вызовом выделить достаточное колво памяти в ней. ??? lpstrFile в структуре ... global type openfilename_multi from structure long lstructsize long hwndowner long hinstance blob lpstrfilter long lpstrcustomfilter long nmaxcustomfilter long nfilterindex blob lpstrfile long nmaxfile blob lpstrfiletitle long nmaxfiletitle string lpstrinitialdir string lpstrtitle long flags integer nfileoffset integer nfileextension string lpstrdefext long lcustdata long lpfnhook long lptemplatename end typ не совсем представляю как сделать её [ ref Blob ] и може я чего не допонял, но: For pos = 1 To Len(blob) Step 2 int char_code = Int(BlobMid(blob, pos, 2)) толжно быть For pos = 1 To Len(blob) Step 2 char_code = int(BlobEdit(blob, pos, 2)) ??? не??? полюбому, For pos = 1 To Len(st_open.lpstrfile) Step 2 char_code = int(BlobEdit(st_open.lpstrfile, pos, 2)) If char_code = 0 Then If prev_pos = pos - 1 Then Exit // last 0 ls_string = String(BlobMid(st_open.lpstrfile, prev_pos + 1, pos - prev_pos)) messagebox('', ls_string) // add ls_string somewhere prev_pos = pos End If Next ничего не происходит. ... |
|||
:
Нравится:
Не нравится:
|
|||
17.10.2014, 19:50 |
|
Комрады, доброго всем времени суток. Кто в настроении, подсобите plz, как blob разодрать?
|
|||
---|---|---|---|
#18+
декларация (global external function for application): Function long GetOpenFileNameMulti(REF OPENFILENAME_MULTI OpenFileName_Multi) library "comdlg32.dll" alias for "GetOpenFileNameW;Unicode" объект (структура): global type openfilename_multi from structure long lstructsize long hwndowner long hinstance blob lpstrfilter long lpstrcustomfilter long nmaxcustomfilter long nfilterindex blob lpstrfile long nmaxfile blob lpstrfiletitle long nmaxfiletitle string lpstrinitialdir string lpstrtitle long flags integer nfileoffset integer nfileextension string lpstrdefext long lcustdata long lpfnhook long lptemplatename end type вызов функции из окна: int i_rc string s_fname1, s_fname2 i_rc = f_get_file_open_name_multi(This, '', 'Extensible Markup Language (*.xml), *.xml', g_s_home_path, 'Select File To Transmit', '.xml', s_fname1, s_fname2) сама функция: global type f_get_file_open_name_multi from function_object end type forward prototypes global function long f_get_file_open_name_multi (window a_w_caller, string a_s_def_file_name, string a_s_file_type, string a_s_file_dir, string a_s_popup_title, string a_s_def_ext, ref string ar_s_full_name, ref string ar_s_short_name) end prototypes global function long f_get_file_open_name_multi (window a_w_caller, string a_s_def_file_name, string a_s_file_type, string a_s_file_dir, string a_s_popup_title, string a_s_def_ext, ref string ar_s_full_name, ref string ar_s_short_name); blob{1000} bl_filter openfilename_multi st_open ULong l_result char c_filter[1000] long l_idx, l_str_size, l_start_pos, l_len int i_rc, i_pos string s[], s_null, s_char l_start_pos=1 l_start_pos = Pos(a_s_def_file_name, '/', l_start_pos) DO WHILE l_start_pos > 0 a_s_def_file_name = Replace(a_s_def_file_name, l_start_pos,1, '-') l_start_pos = Pos(a_s_def_file_name, '/', l_start_pos + 1) LOOP //---------------------------------- // File Constants //---------------------------------- CONSTANT ulong OFN_NOLONGNAMES = 262144 //&H40000 CONSTANT ulong OFN_NONETWORKBUTTON = 131072 //&H20000 CONSTANT ulong OFN_NOREADONLYRETURN = 32768 //&H8000 CONSTANT ulong OFN_NOTESTFILECREATE = 65536 //&H10000 CONSTANT ulong OFN_READONLY = 1 //&H1 CONSTANT ulong OFN_OVERWRITEPROMPT = 2 //&H2 CONSTANT ulong OFN_HIDEREADONLY = 4 //&H4 CONSTANT ulong OFN_NOCHANGEDIR = 8 //&H8 CONSTANT ulong OFN_SHOWHELP = 16 //&H10 CONSTANT ulong OFN_ENABLEHOOK = 32 //&H20 CONSTANT ulong OFN_ENABLETEMPLATE = 64 //&H40 CONSTANT ulong OFN_ENABLETEMPLATEHANDLE = 128 //&H80 CONSTANT ulong OFN_NOVALIDATE = 256 //&H100 CONSTANT ulong OFN_EXTENSIONDIFFERENT = 1024 //&H400 CONSTANT ulong OFN_PATHMUSTEXIST = 2048 //&H800 CONSTANT ulong OFN_FILEMUSTEXIST = 4096 //&H1000 CONSTANT ulong OFN_CREATEPROMPT = 8192 //&H2000 CONSTANT ulong OFN_SHAREAWARE = 16384 //&H4000 CONSTANT ulong OFN_NODEREFERENCELINKS = 1048576 //&H100000 CONSTANT ulong OFN_LONGNAMES = 2097152 //&H200000 CONSTANT ulong OFN_SHARENOWARN = 1 CONSTANT ulong OFN_SHAREFALLTHROUGH = 2 CONSTANT ulong OFN_SHAREWARN = 0 CONSTANT ulong OFN_EXPLORER = 524288 //&H80000/* 0x00080000 */ CONSTANT ulong OFN_ALLOWMULTISELECT = 512 //&H200/* 0x00000200 */ SetNull(s_null) bl_filter = Blob(a_s_file_type) c_filter = a_s_file_type FOR l_idx = 1 TO len(a_s_file_type) IF string(c_filter[l_Idx]) = ',' THEN BlobEdit(bl_filter, (l_idx * 2) - 1 , Char(0)) END IF NEXT st_open.lstructsize = 76 st_open.hwndowner = Handle(a_w_caller) st_open.hInstance = 0 st_open.lpstrfilter = bl_filter st_open.lpstrcustomfilter = 0 st_open.nmaxcustomfilter = 0 st_open.nfilterindex = 1 st_open.lpstrfile = blob(space(15000))///* for multi select */ blob (space(2047990)) // for single select - a_s_def_file_name + space(15000) st_open.nmaxfile = len(st_open.lpstrfile) + 1 /* for multiselect 2048000 // for single select - len(st_open.lpstrfile) + 1 */ st_open.lpstrfiletitle = blob(s_null) st_open.nmaxfiletitle = 138 st_open.lpstrinitialdir = a_s_file_dir st_open.lpstrtitle = a_s_popup_title st_open.flags = OFN_ALLOWMULTISELECT + OFN_EXPLORER st_open.nfileoffset = 0 st_open.nfileextension = 0 st_open.lpstrdefext = a_s_def_ext st_open.lcustdata = 0 st_open.lpfnhook = 0 st_open.lptemplatename = 0 i_rc = GetOpenFileNameMulti(st_open) int prev_pos = 0, pos, char_code string ls_string For pos = 1 To Len(st_open.lpstrfile) Step 2 char_code = int(BlobEdit(st_open.lpstrfile, pos, 2)) If char_code = 0 Then If prev_pos = pos - 1 Then Exit // last 0 ls_string = String(BlobMid(st_open.lpstrfile, prev_pos + 1, pos - prev_pos)) messagebox('', ls_string) // add ls_string somewhere prev_pos = pos End If Next RETURN i_rc end function ... |
|||
:
Нравится:
Не нравится:
|
|||
17.10.2014, 20:02 |
|
Комрады, доброго всем времени суток. Кто в настроении, подсобите plz, как blob разодрать?
|
|||
---|---|---|---|
#18+
voronkМожно нам перейти на ТЫ? Я обращаюсь на вы, но не против, чтобы ко мне на ты :) voronkне совсем представляю как сделать её [ ref Blob ] А, тут я напутал. Не надо ее делать ref. Я упустил что lpstrfile не отдельный параметр , а поле структуры. Достаточно, как у вас, саму структуру сделать Ref в описании внешней ф-и. voronkFor pos = 1 To Len(blob) Step 2 int char_code = Int(BlobMid(blob, pos, 2)) толжно быть For pos = 1 To Len(blob) Step 2 char_code = int(BlobEdit(blob, pos, 2)) Не. Точно не BlobEdit (BlobEdit это модификация блоба, а вам надо его читать). Но у меня в коде тоже ошибка (сорри успел подзабыть язык) Объявление нужно выделить в отдельную строку иначе присвоение будет произведено однократно и вовсе не в тот момент когда надо. Код: sql 1. 2.
Попробуйте пофиксить сначала это. PS. Хотя, я только что нагуглил вот это http://pbminer.dwox.com/Sources/TopWiz/zlibwapi/PB10/n_getopenfilename.sru Похоже на готовый код обвязки для этой функции с поддержкой мультиселекта. Так что вероятно стоит начать с него. ... |
|||
:
Нравится:
Не нравится:
|
|||
18.10.2014, 03:08 |
|
Комрады, доброго всем времени суток. Кто в настроении, подсобите plz, как blob разодрать?
|
|||
---|---|---|---|
#18+
ls_string = String(BlobMid(blob, prev_pos + 1, pos - prev_pos)) не хочет работать. цепляю два файла, path, т.е. набор символов до первого [null] выдаeт как положенно:C:\Users\Administrator\Documents\New Folder\ а вот потом, несмотря на то что ls_string = char(char_code) выдаёт правильную букву за буквой, результат: ls_string = String(BlobMid(st_open.lpstrfile, prev_pos + 1, pos - prev_pos)) первого файла: 㤀㤀⸀䴀甀氀琀椀⸀匀愀洀瀀氀攀⸀砀洀氀 а второго: 一䔀䰀䌀伀开 㤀㤀开嘀椀氀氀愀猀倀䠀开㈀ 㐀 㤀㈀㔀㘀㜀⸀堀䴀䰀 я и так и так крутил, потом немного код переделал и получил то что мне надо ... аррэй с набором имён файлов: For pos = 1 To Len(blob) Step 2 char_code = Integer(BlobMid(blob, pos, 2)) ls_string = char(char_code) If char_code = 0 Then s_files_list[i_cnt] = s_file_name i_cnt ++ s_file_name = '' If prev_pos = pos - 1 Then Exit // last 0 end if //ls_string = String(BlobMid(blob, prev_pos + 1, pos - prev_pos)) prev_pos = pos else s_file_name = s_file_name + ls_string End If Next пока работает, потом может вернусь и докапаюсь СПАСИБО вам большое Алексей !!! :drink1: ... |
|||
:
Нравится:
Не нравится:
|
|||
20.10.2014, 22:55 |
|
Комрады, доброго всем времени суток. Кто в настроении, подсобите plz, как blob разодрать?
|
|||
---|---|---|---|
#18+
voronkСПАСИБО вам большое Алексей !!! Я ему передам ... |
|||
:
Нравится:
Не нравится:
|
|||
21.10.2014, 00:44 |
|
|
start [/forum/topic.php?fid=15&fpage=9&tid=1335304]: |
0ms |
get settings: |
10ms |
get forum list: |
14ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
30ms |
get topic data: |
13ms |
get forum data: |
2ms |
get page messages: |
100ms |
get tp. blocked users: |
2ms |
others: | 244ms |
total: | 423ms |
0 / 0 |