Home > database >  A small question again
A small question again

Time:09-27

In PB how to obtain the address of the variable? Thank you very much!

CodePudding user response:

See the help file, remember where as seen, no check, forgive me

CodePudding user response:

How to get the address of a string variable in the PB
In PB, often need to call some dynamic library (DLL) to realize the function expansion, but the DLL is usually written language or Delphi, C often

Will use a pointer, pointer parameter is often comes from the form, even though the PB can add REF keyword to indicate the delivery address is parameters, but the actual use of the

But often some unexpected results, I've been calling on a DLL, use the REF pass a string to DLL, but in the end the DLL is taken a series of

Noise, it's the wrong explanation to the address of the DLL, the DLL to other memory blocks of data, at this point, the PB can only hope to buy the needle,

In fact, in some cases, we are still able to use some other alternative way to insinuate operation pointer, below is my actual use by

Windows API to get to the address of the string methods:

Firstly, declare an API function:

The Function long lstrcpy (ref string Destination, ref string Source) library "kernel32. DLL" ALIAS FOR

"Lstrcpy; ANSI ";



Second, and then call the function to get the string above address:

String ls_src, ls_dst
Long ll_address

Ls_src="https://bbs.csdn.net/topics/PB" how to get the address of a string variable
Ls_dst=space (255)
Ll_address=lstrcpy (ls_dst ls_src)

So, get is the address of the string ls_dst ll_address, I have a C language to write a DLL, which is a function like this:

Void __stdcall ChangePrinterSetting (LPTSTR pCustomFormName, SIZEL * FormSize);

According to the normal way, in the PB should such statement and call:

The public FUNCTION Integer ChangePrinterSetting (REF string formName, REF STRU_SIZEL size) LIBRARY

"PrnSet. DLL" ALIAS FOR "ChangePrinterSetting; ANSI ";



String ls_fromName

STRU_SIZEL size;

Ls_fromName="my form format"

Cx=100000
the size.
Size. The cy=200000

ChangePrinterSetting ls_fromName, size ()

But such calls, actual operation found that the DLL is garbled, taken that the REF keyword passed to the parameters of the DLL address wrong, so I changed to such a party

Type:

The public FUNCTION Integer ChangePrinterSetting (long formName, REF STRU_SIZEL size) LIBRARY "PrnSet. DLL
"
ALIAS FOR "ChangePrinterSetting; ANSI ";



String ls_fromName, ls_temp

STRU_SIZEL size;

Ls_fromName="my form format"

Ls_temp=space (255)
Ll_address=lstrcpy (ls_temp ls_fromName)

Cx=100000
the size.
Size. The cy=200000

ChangePrinterSetting ll_address, size ()

In this way, he took to the correct Chinese string in a DLL, so how to write a few lines of code, save the parameters passed correctly, and also is no way to do something,



Always speaking, PB for rapid development of database application has its unique advantages, but encounter need to extend the functionality, with a third party language is

Ragged,

CodePudding user response:

Code,,,,

CodePudding user response:

Learning, thank you for your offer,

CodePudding user response:

To study the

CodePudding user response:

Tell you to write an API:
ULONG WINAPI getpointer (LPVOID Variable)

PB:

The function ulong getpointer (ref string s)...
The function ulong getpointer (ref char s)...
The function ulong getpointer (ref long s)...
.

Don't think you understand, look not to understand, don't ask for more,,,,


CodePudding user response:

Function body forget wrote:
ULONG WINAPI getpointer (LPVOID Variable)
{
Return (ULONG) Variable;
}

CodePudding user response:

To study the

CodePudding user response:

It seems is a profound problem.

CodePudding user response:

Try ~ ~ ok `

CodePudding user response:

Has a problem directly after looting new brother went, the brothers too much inventory, ha ha

CodePudding user response:

CodePudding user response:

refer to the second floor newease response:
PB in how to get the address of a string variable
In PB, often need to call some dynamic library (DLL) to realize the function expansion, but the DLL is usually written language or Delphi, C often

Will use a pointer, pointer parameter is often comes from the form, even though the PB can add REF keyword to indicate the delivery address is parameters, but the actual use of the

But often some unexpected results, I've been calling on a DLL, use the REF pass a string to DLL, but in the end the DLL is taken a series of
.

 
How can have the code? Don't understand!
BOOL AddOpenCom (LPCTSTR coms, LPCTSTR commset, LPCTSTR outerr_text)
{
__try
{

COMHREAD * h;

If (FindCom (coms))
Return TRUE;

H=Initializationcomobj (coms, commset);
if(! OpenCom (& amp; H - & gt; Com. Hcom, coms, commset, TRUE, outerr_text))
{
DeleteComobj (h);
Return FALSE;
}

H - & gt; Com. Portopen=TRUE;
if(! Comobjs)
{
Comobjs=h;
}
The else
{
Comobjs - & gt; The back=h;
H - & gt; Next=comobjs;
Comobjs=h;
}
: : InitializeCriticalSection (& amp; H - & gt; Com. Cs);
H - & gt; Comthread=CreateThread (NULL, 0, ListenThread, (LPVOID) h, 0, NULL);

Return TRUE;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
Sprintf (outerr_text (CHAR *), "the unknown error occurred!" );
Return FALSE;
}
}

The function BOOLean AddOpenCom (ref string coms, ref string commset, ref string outerr_text) library "vscomm. DLL" alias for "AddOpenCom; Ansi
"
If isnull (com) then return
Try

Datastore rs; Rs=create the datastore; Rs. Dataobject="d_coms_select"; Rs. Settransobject (sqlca)
Rs. Setsqlselect (rs. Getsqlselect () + "and fact_no='" + as_fact_no +"' and com='" + com + "' "); Rs. Retrieve ()
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related