質問編集履歴
4
呼出し処理を追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -116,4 +116,37 @@
|
|
116
116
|
process.WaitForExit();
|
117
117
|
process.Close();
|
118
118
|
}
|
119
|
+
```
|
120
|
+
ボタンクリック時の処理
|
121
|
+
```C#
|
122
|
+
Task task2 = Task.Run(() => {
|
123
|
+
UtlSendEx(
|
124
|
+
HULFTのファイルID,
|
125
|
+
送信先のホスト名,
|
126
|
+
送信対象のファイルパス,
|
127
|
+
メッセージ1,
|
128
|
+
メッセージ2,
|
129
|
+
同期、非同期フラグ,
|
130
|
+
同期転送時の処理結果待ち時間
|
131
|
+
);
|
132
|
+
});
|
133
|
+
Task task1 = Task.Run(() => { cancelDialog.ShowDialog(); });
|
134
|
+
task2.Wait();
|
135
|
+
|
136
|
+
if(cancelDialog != null || !cancelDialog.IsDisposed)
|
137
|
+
{
|
138
|
+
task1.Dispose();
|
139
|
+
}
|
140
|
+
```
|
141
|
+
キャンセルダイアログの処理
|
142
|
+
```C#
|
143
|
+
public CancelDialog()
|
144
|
+
{
|
145
|
+
InitializeComponent();
|
146
|
+
}
|
147
|
+
|
148
|
+
private void btnOk_Click(object sender, EventArgs e)
|
149
|
+
{
|
150
|
+
CancelUpLoad(HULFTのファイルID)
|
151
|
+
}
|
119
152
|
```
|
3
キャンセル処理のコード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -105,4 +105,15 @@
|
|
105
105
|
}
|
106
106
|
}
|
107
107
|
}
|
108
|
+
|
109
|
+
// 配信キャンセルコマンド
|
110
|
+
public virtual void CancelUpload(string fileId)
|
111
|
+
{
|
112
|
+
Process process = new Process();
|
113
|
+
process.StartInfo.FileName = "utlscan";
|
114
|
+
process.StartInfo.Arguments = string.Format("-f \"{0}\"", fileId);
|
115
|
+
process.Start();
|
116
|
+
process.WaitForExit();
|
117
|
+
process.Close();
|
118
|
+
}
|
108
119
|
```
|
2
配信要求処理のソース追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,4 +13,96 @@
|
|
13
13
|
プログラムから外部機能を呼び出した場合と、コマンドプロンプトなどから直接起動した場合では何か違うのでしょうか?
|
14
14
|
|
15
15
|
この現象の原因がわからず困り果てています…。
|
16
|
-
何か原因特定のためのアドバイスがありましたらご教授願います。
|
16
|
+
何か原因特定のためのアドバイスがありましたらご教授願います。
|
17
|
+
|
18
|
+
追記
|
19
|
+
HULFTの配信要求を行うメソッドの定義です。
|
20
|
+
フォームのボタンクリックでこのメソッドを呼出し、配信要求~ファイル送信処理は問題無く行えています。
|
21
|
+
```C#
|
22
|
+
//配信要求拡張API定義
|
23
|
+
[DllImport("hulapi.dll", SetLastError = true, EntryPoint = "utlsendex")]
|
24
|
+
private static extern int _hulapi_utlsendex(
|
25
|
+
string lpszFileID,
|
26
|
+
string lpszHostName,
|
27
|
+
bool bRsend,
|
28
|
+
short nPriority,
|
29
|
+
bool bSync,
|
30
|
+
int nWait,
|
31
|
+
string lpszFileName,
|
32
|
+
IntPtr group,
|
33
|
+
bool bNp,
|
34
|
+
IntPtr lpMsg,
|
35
|
+
int nTransMode
|
36
|
+
);
|
37
|
+
|
38
|
+
//配信要求拡張APIのラッパーメソッド
|
39
|
+
public static int UtlSendEx(string FileID, string HostName, string FileName, string[] Msgs, string[] exMsgs, bool isAsync, int wait)
|
40
|
+
{
|
41
|
+
IntPtr tagptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * 3);
|
42
|
+
uint infoptr = (uint)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * 6);
|
43
|
+
uint[] msgarr = new uint[6];
|
44
|
+
for (int i = 0; i < 6; i++)
|
45
|
+
{
|
46
|
+
msgarr[i] = (uint)Marshal.AllocHGlobal(51);
|
47
|
+
for (int k = 0; k < 51; k++)
|
48
|
+
{
|
49
|
+
Marshal.WriteByte((IntPtr)(msgarr[i] + k), (byte)0);
|
50
|
+
}
|
51
|
+
if (Msgs != null && i < Msgs.Length)
|
52
|
+
{
|
53
|
+
int offset = 0;
|
54
|
+
foreach (char c in Msgs[i].ToCharArray())
|
55
|
+
{
|
56
|
+
Marshal.WriteByte((IntPtr)(msgarr[i] + offset), (byte)c);
|
57
|
+
offset++;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
Marshal.WriteInt32((IntPtr)(infoptr + i * Marshal.SizeOf(typeof(IntPtr))), (int)msgarr[i]);
|
61
|
+
}
|
62
|
+
uint exptr = (uint)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * 2);
|
63
|
+
uint[] exarr = new uint[2];
|
64
|
+
for (int i = 0; i < 2; i++)
|
65
|
+
{
|
66
|
+
exarr[i] = (uint)Marshal.AllocHGlobal(201);
|
67
|
+
for (int k = 0; k < 201; k++)
|
68
|
+
{
|
69
|
+
Marshal.WriteByte((IntPtr)(exarr[i] + k), (byte)0);
|
70
|
+
}
|
71
|
+
if (exMsgs != null && i < exMsgs.Length)
|
72
|
+
{
|
73
|
+
int offset = 0;
|
74
|
+
foreach (char c in exMsgs[i].ToCharArray())
|
75
|
+
{
|
76
|
+
Marshal.WriteByte((IntPtr)(exarr[i] + offset), (byte)c);
|
77
|
+
offset++;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
Marshal.WriteInt32((IntPtr)(exptr + i * Marshal.SizeOf(typeof(IntPtr))), (int)exarr[i]);
|
81
|
+
}
|
82
|
+
Marshal.WriteInt32(tagptr, 8);
|
83
|
+
Marshal.WriteInt32((IntPtr)((uint)tagptr + Marshal.SizeOf(typeof(IntPtr))), (int)infoptr);
|
84
|
+
Marshal.WriteInt32((IntPtr)((uint)tagptr + Marshal.SizeOf(typeof(IntPtr)) * 2), (int)exptr);
|
85
|
+
try
|
86
|
+
{
|
87
|
+
return _hulapi_utlsendex(FileID, HostName, false, 0, isAsync, wait, FileName, (IntPtr)0, false, tagptr, 0);
|
88
|
+
}
|
89
|
+
catch (DllNotFoundException e)
|
90
|
+
{
|
91
|
+
return -1;
|
92
|
+
}
|
93
|
+
finally
|
94
|
+
{
|
95
|
+
Marshal.FreeHGlobal(tagptr);
|
96
|
+
Marshal.FreeHGlobal((IntPtr)infoptr);
|
97
|
+
for (int i = 0; i < 6; i++)
|
98
|
+
{
|
99
|
+
Marshal.FreeHGlobal((IntPtr)msgarr[i]);
|
100
|
+
}
|
101
|
+
Marshal.FreeHGlobal((IntPtr)exptr);
|
102
|
+
for (int i = 0; i < 2; i++)
|
103
|
+
{
|
104
|
+
Marshal.FreeHGlobal((IntPtr)exarr[i]);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
```
|
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
Windows FormsとHULFTを組み合わせて、ファイル転送機能を持った画面を開発しています。
|
2
2
|
|
3
|
+
開発環境
|
4
|
+
Windows10
|
5
|
+
.NetFramework4.6
|
6
|
+
HULFT 8
|
7
|
+
|
8
|
+
|
3
9
|
フォームのボタンクリックイベントでHULFTの配信要求を実行後に、コマンドプロンプトから配信キャンセルコマンドを実行すると「__指定したファイルIDに該当するものがありません__」のようなメッセージが返され、配信のキャンセルができません。
|
4
10
|
|
5
11
|
コマンドプロンプトを2つ開いて、プログラムに設定しているのと同じファイルIDで配信要求後に配信キャンセルを行うと正常にキャンセルされます。
|
6
12
|
|
13
|
+
プログラムから外部機能を呼び出した場合と、コマンドプロンプトなどから直接起動した場合では何か違うのでしょうか?
|
14
|
+
|
7
15
|
この現象の原因がわからず困り果てています…。
|
8
16
|
何か原因特定のためのアドバイスがありましたらご教授願います。
|