Windows system casting

2016-06-06 Thread Alexander Patapoff via Digitalmars-d-learn

import std.stdio;
import std.string;
import core.sys.windows.windows;
void main() {

	string filepath = 
"C:\\Users\\awpat\\Pictures\\patterns_00387591.jpg";

auto p = toStringz(filepath);

int result;
	result = SystemParametersInfo(cast(uint)SPI_SETDESKWALLPAPER, 
cast(uint)0, cast(void*)p ,cast(uint)SPIF_UPDATEINIFILE);


}

I'm trying to change the background of my computer. to do this I 
must convert my string to a const char*, then that can implicitly 
to a (PVOID). I believe that I am losing all my data in the 
casting process, is there a way for me to keep my data? or if I 
am casting this improperly can you demonstrate and explain the 
proper way to cast to a void pointer (PVOID)?



thanks!!


Re: Interfaces

2016-04-09 Thread alexander Patapoff via Digitalmars-d-learn

On Saturday, 9 April 2016 at 08:59:13 UTC, ag0aep6g wrote:

On 09.04.2016 10:45, alexander Patapoff wrote:

[...]


There is a somewhat obscure feature which lets you declare and 
instantiate a class at the same time:



interface Action
{
  void actions(int x);
}

void main()
{
  Action action = new class Action {
  void actions(int x) {/* ... */}
  };
}


http://dlang.org/spec/class.html#anonymous


Yaaay! thank you!


Interfaces

2016-04-09 Thread alexander Patapoff via Digitalmars-d-learn
is there a way for me to do this in D? In java, one is able to 
create a new instance of an interface.


interface Action
{
  void actions(T t);
}

class testAction
{
  this()
   {
Action action = new Action()
   {
 void actions(T t){...}
   }
   }

}

I found this feature really useful in java. Is there any way I 
can duplicate this process, without the mixin func?