Страница 1 из 1

Все что нажито непосильным трудом .... ?

Добавлено: 21 Ноябрь 2007, 14:37
Игорь Столяров
Начал разбираться с .Net вообще и Clarion# в частности.
Даже книжку присмотрел, может быть даже куплю за деньги ...

Возник главный вопрос - принцип изоляции приложения в .Net в принципе исключает доступ к WinApi. Т.е. все что наработано с WinApi (HTTP, FTP, CryptoApi и т.д.) можно начинать делать заново ?! Старый код работы с WinApi под .Net работать не будет ?! Если это так - то это кошмар .... или я сам себя без причины пугаю ?

Добавлено: 21 Ноябрь 2007, 14:54
Admin
Думаю не все так плохо. Если даже и так то взамен открывается все богатство компонентов .Net и т.д.

Добавлено: 21 Ноябрь 2007, 15:23
Дед Пахом
Не исключает. Есть P/Invoke (PlatformInvoke), позволяющее пользоваться WinAPI. В C# это делается так:
[DllImport("user32.dll")]
public static extern int SetParent(int hWndChild, int hWndNewParent);

Platform Invocation Service Support (PInvoke)

Добавлено: 22 Ноябрь 2007, 14:36
Admin
Смотрим справку в Clarion.Net

Platform Invocation Services (PInvoke) allows managed code (code executed by the Common Language Runtime) to call unmanaged functions (i.e., COM components, ActiveX components, Win32 API, etc.) that are implemented in a DLL.

Calling external functions that reside in a DLL uses the Platform Invoke service. It locates and invokes an exported function and marshals (e.g., arranges in a methodical order) its arguments (integers, strings, arrays, structures, and so on) across the interoperation boundary as needed.

To call external procedure you should specify the DLL name and entry point with .NET's DllImportAttribute attribute in the MAP. It uses the default PInvoke marshaling mechanisms, as result, you can only use .Net data types as parameters. There is no specific marshaling behavior support for Clarion-specific types (i.e. CLADECIMAL, CLASTRING, CSTRING, PSTRING, ASTRING).

To customize the default marshaling behavior you can use MarshalAsAttribute (see .Net Framework documentation for details).

Calling external functions in a DLL with Platform Invoke service can be done in two ways:

Clarion# includes support for the .NET's DllImportAttribute attribute:

Код: Выделить всё

[DllImportAttribute("user32.dll", EntryPoint = "MessageBoxW")] MessageBox PROCEDURE(UNSIGNED hWnd, STRING Text, STRING Caption, UNSIGNED Type),SIGNED
Or using Clarion syntax:

Код: Выделить всё

MODULE('user32.dll')
  MessageBox PROCEDURE(SIGNED h,ClaString msg,String cpt,SIGNED tp),SIGNED
END

Добавлено: 22 Ноябрь 2007, 14:39
Admin
Там же смотрим топик с именем "Custom Attributes"