GW2RegisterLicenceMemory
Ang GW2RegisterLicenceMemory ay nagrerehistro ng licence file na nasa memory sa isang session.
Kung alinman sa GW2RegisterLicenceFile o GW2RegisterLicenceMemory ay hindi nakarehistro sa isang session, susubukan ng Editor na hanapin ang licence sa default na lokasyon. Ito ay isang file na tinatawag na gwkey.lic na matatagpuan sa parehong folder ng Editor library. Kung hindi ito mahanap, ituturing ang library na walang lisensya at maaaring mabigo ang ilang proseso dahil sa mga isyu sa pag-expire ng lisensya.
- C++
- C#
- Java
- Python
- JavaScript
Buod
Para sa session na session, ang function na GW2RegisterLicenceMemory ay nagrerehistro ng licence na gagamitin ng Glasswall kapag nagpoproseso ng mga file. Ang licenceContents ay isang pointer sa licence data, at ang licenceLength ay tumutukoy sa laki sa bytes ng licence data.
#include "glasswall.core2.api.h"
int GW2RegisterLicenceMemory(Session session,
const char *licenceContents,
size_t licenceLength);
Ibinabalik
Nagbabalik ng integer na GW2_RetStatus enum value. Ang mga negatibong numero ay nagpapahiwatig ng pagkabigo.
Halimbawa
#include "glasswall.core2.api.h"
Session session = GW2OpenSession();
char *licence = NULL;
size_t size = 0;
if (!session)
/* deal with error */
else
{
/* ... load 'licence' with a pointer to the licence content ... */
if (GW2RegisterLicenceMemory(session, licence, size) < 0)
/* deal with error */
else
/* continue processing */
}
. . .
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
Buod
Para sa session na session, ang method na RegisterLicenceMemory ay nagrerehistro ng licence na gagamitin ng Glasswall kapag nagpoproseso ng mga file.
/// <summary>
/// Provide a licence to use for the session.
/// </summary>
/// <param name="session">Current open Glasswall session</param>
/// <param name="licence">Byte content of the licence</param>
public int RegisterLicenceMemory(int session, byte[] licence)
Ibinabalik
Nagbabalik ng integer na GW2_RetStatus enum value. Ang mga negatibong numero ay nagpapahiwatig ng pagkabigo.
Buod
import com.glasswall.core2javabridge.*;
public int GW2RegisterLicenceMemory(int session, byte[] licenceBuffer) throws GlasswallException, NullPointerException
public int GW2RegisterLicenceMemory(int session, byte[] licenceBuffer, int licenceLength) throws GlasswallException, NullPointerException
Tandaan
Ang length ng licenceBuffer ay maaaring tukuyin bilang opsyonal.
Ibinabalik
Ang function na GW2RegisterLicenceMemory ay nagbabalik ng GW2_RetStatus enumeration na kino-convert sa int. Magiging negative ang value kung may naganap na error. Ang 0 ay nagpapahiwatig ng tagumpay. Sumangguni sa API Overview/Return types para sa mga detalye.
Isang GlasswallException exception ang ita-throw kung hindi valid ang session.
Magkakaroon ng NullPointerException exception kung ang licenceBuffer buffer ay null o walang laman.
Ang licence registration para sa bawat session ay awtomatikong pinangangasiwaan sa Python wrapper, at hindi kinakailangan para sa mga user na tawagin nang manu-mano ang GW2RegisterLicenceFile o GW2RegisterLicenceMemory.
Bilang default, inaasahan ng class na Editor na ang isang wastong licence file ay matatagpuan sa parehong directory ng library_path. Maaari ka ring tumukoy ng ibang path sa isang gwkey.lic licence file gamit ang argument na licence.
import glasswall
# Load the Glasswall Editor library with a specified licence file
editor = glasswall.Editor(r"C:\gwpw\libraries\10.0", licence=r"C:\gwpw\licence\gwkey.lic")
Bilang alternatibo, maaari mong ipasa ang licence data sa in-memory bilang isang bytes, bytearray, o io.BytesIO object.
import glasswall
# Alternatively, load the licence from in-memory bytes or bytearray
with open(r"C:\gwpw\licence\gwkey.lic", "rb") as f:
licence_data = f.read()
editor = glasswall.Editor(
r"C:\gwpw\libraries\10.0",
licence=licence_data # In-memory licence data
)
Buod
Para sa session na session, ang function na GW2RegisterLicenceMemory ay nagrerehistro ng licence na gagamitin ng Glasswall kapag nagpoproseso ng mga file. Ang licenceContents ay isang pointer sa licence data, at ang licenceLength ay tumutukoy sa laki sa bytes ng licence data.
/**
* Provides the contents of the licence file that will be used for this session.
* @param {number} session The ID of the session.
* @param {string} licenceContents A pointer to the licence data buffer.
* @param {number} licenceLength Length of the data in the licence buffer.
* @returns {number} Status of the operation; 0 for success, non-zero for failure.
*/
GW2RegisterLicenceMemory(session, licenceContents, licenceLength)
Ibinabalik
Nagbabalik ng integer na GW2_RetStatus enum value. Ang mga negatibong numero ay nagpapahiwatig ng pagkabigo.